我制作了过渡动画。所以如果状态改变,那么就会发出转换。这是我制作的顺序动画。
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 继续运行,尽管我已经将 running 属性设置为 false ...