CardTransition 模式有问题吗?

Are CardTransition modes bugged?

我尝试在 kivy 中使用 CardTransition。我想让'OtherScreen'从右边滑动,回去的时候会往回滑动。我尝试使用 'push' 和 'pop' 作为模式

我试过只使用 'push',它有效,或者只使用 'pop',它也有效,但我似乎无法将两者结合起来

'''

MainScreen:
    name: 'main'

    FloatLayout:
        size: root.width, root.height
        canvas.before:
            Color:
                rgba: 1, 1, 1, 1
            Rectangle:
                size: root.width, root.height

        Button:
            text: '2D'
            size: root.height / 2.5, root.height / 2.5
            size_hint: None, None
            pos_hint: {'center_y': 0.75, 'center_x': 0.5}
            on_press:
                app.root.current = '2d'
                root.manager.transition.direction = "left"
                **root.manager.transition.mode = 'push'**       *# this is push*

            font_size: 50
            background_normal: 'ok.png'


OtherScreen:
    name: '2d'

    FloatLayout:
        size: root.width, root.height

        Button:
            on_press:
                app.root.current = 'main'
                root.manager.transition.direction = "right"
                **root.manager.transition.mode = 'pop'**     *# and this is pop*

            text: 'back'

'''

点击第一个按钮后,'OtherScreen'滑入,但之后动画完全消失

根本原因

CardTransition 没有像您预期的那样工作,因为在您的应用中,它在设置方向之前切换了屏幕。

片段

        on_press:
            app.root.current = '2d'
            root.manager.transition.direction = "left"
        ...
        on_press:
            app.root.current = 'main'
            root.manager.transition.direction = "right"

解决方案

  1. 设置过渡方向
  2. 切换画面

片段

        on_press:
            root.manager.transition.direction = "left"
            app.root.current = '2d'
        ...
        on_press:
            root.manager.transition.direction = "right"
            app.root.current = 'main'