3

トランジションでアニメーションを作りました。したがって、状態が変化すると、遷移が放出されます。これが私が作ったシーケンシャルアニメーションです。

SequentialAnimation{
            PropertyAnimation{
                properties: "width"
                duration: 300
            }
            PropertyAnimation{
                properties: "x"
                duration: 500
            }
            Component.onCompleted: {
                var idx = Math.ceil(Math.random()*2);
                if(idx===0){
                    anim0.running = true
                    anim1.running = false
                }
                else {
                    anim1.running = true
                    anim0.running = false
                }
                console.log("haha");
            }
        }

        SequentialAnimation{
            id: anim0
            running: false
            NumberAnimation{
                running: anim0.running
                properties: "x"
                to: 300
                duration: 500
            }
            Component.onCompleted: console.log("anim0");
        }
        SequentialAnimation{
            id: anim1
            running: false
            NumberAnimation{
                running: anim1.running
                properties: "x"
                to: -300
                duration: 500
            }
            Component.onCompleted: console.log("anim1");
        }

Component.onCompletedシグナルで最初にJavaScriptを無視します。ID:anim1とanim0のSequencialAnimationは、実行属性をfalseに設定していても、実行を続けます。

4

1 に答える 1

1

runningアイテムのプロパティAnimationをfalseに設定しても、アニメーションの開始が妨げられることはありません。現在実行中の場合は停止します。

トランジションでアニメーションを開始したくない場合は、トランジション内にアニメーションを配置しないでください。の外でいつでもカスタムAnimationアイテムを定義Transitionし、関数を使用して必要なときにトリガーすることができますanimationId.start()

詳細については、ドキュメントページを参照してください。

于 2012-12-12T08:34:10.170 に答える