有窗口,其布局由states and transition
设计。我们知道当状态发生变化时,transition-animation
会自动启动,但是当过渡动画没有完成时,我会改变状态,这会造成麻烦。就像slow in reacting
;怎么解决?谢谢......
它是这样的:
Flickable {
id: content anchors.fill: parent flickableDirection: Flickable.HorizontalFlick contentWidth: width * 2 contentHeight: height clip: true onFlickStarted: { if(horizontalVelocity > 0) { regAndFind.state = "Find" } else { regAndFind.state = "Register" } } ....... }
states: [
State {
name: "Register"
PropertyChanges {
target: slider
x: 0
}
PropertyChanges {
target: content
contentX: 0
}
},
State {
name: "Find"
PropertyChanges {
target: slider
x: parent.width / 2
}
PropertyChanges {
target: content
contentX: parent.width
}
}
]
transitions: [
Transition {
NumberAnimation {
target: slider
property: "x"
duration: 600
}
NumberAnimation {
target: content
property: "contentX"
duration: 600
}
}
]
答案 0 :(得分:1)
了解Qml中的animation element。
在转移到其他状态之前,您可以调用Animation::stop ()
函数来停止其间的动画。请注意,它将立即停止动画,动画将不会对属性值产生进一步影响。