我在过渡中制作了动画。因此,如果状态更改,则会触发过渡。这是我制作的顺序动画。
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代码。 尽管我已将running属性设置为false,但id为anim1和anim0的SequencialAnimation仍然在运行...
running
属性设置为true? - TheHuge_