Is this behavior of SpringAnimation normal?
QML and Qt Quick
1
Posts
1
Posters
484
Views
1
Watching
-
Have a quick look at the code below. If you run it and spam the button, you will notice that it wont return to its desired position. This wont happen if you click it slowly and wait for the animation to finish.
If instead of a
SpringAnimationanimation you usePropertyAnimationthen the problem disappears.Is this normal, or a bug ?
import QtQuick 2.2 import QtGraphicalEffects 1.0 Item { id: menuButton state: "Closed" Rectangle { id: menuButtonIcon anchors.centerIn: parent //color: Qt.lighter("#C02A25", 1.25) color: "#D23F31" width: 65; height: 65; radius: width * 0.5 antialiasing: true visible: false; } DropShadow { id: menuButtonIconShadow source: menuButtonIcon anchors.fill: source width: source.width height: source.height cached: true radius: 8.0 samples: 16 color: "#60000000" smooth: true horizontalOffset: 0.0 verticalOffset: 0.0 spread: 0.2 transparentBorder: true } Rectangle { id: menuButtonIconBar1 anchors.centerIn: menuButtonIcon width: 17 height: 3 antialiasing: true } Rectangle { id: menuButtonIconBar2 anchors.centerIn: menuButtonIcon width: 17 height: 3 antialiasing: true rotation: 90 } MouseArea { id: mouseArea anchors.fill: menuButtonIcon onPressed: menuButton.state = menuButton.state === "Open" ? "Closed" : "Open" //onClicked: menuButton.state = menuButton.state === "Open" ? "Closed" : "Open" } states: [ State { name: "Closed" }, State { name: "Open" PropertyChanges { target: menuButtonIconBar1; rotation: 135; scale: 0.92} PropertyChanges { target: menuButtonIconBar2; rotation: 225; scale: 0.92} PropertyChanges { target: menuButtonIconShadow; scale: 0.92} } ] transitions: [ Transition { //RotationAnimation { target: menuButtonIconBar1; properties: "rotation"; duration: 400; easing.type: Easing.InOutQuad } //PropertyAnimation { target: menuButtonIconBar2; properties: "rotation"; duration: 400; easing.type: Easing.InOutQuad } //PropertyAnimation { target: menuButtonIconShadow; properties: "scale"; duration: 400; easing.type: Easing.InOutQuad } SpringAnimation { target: menuButtonIconShadow; properties: "scale"; spring: 3; damping: 0.25; epsilon: 0.2; mass: 1; modulus: 0; velocity: 0 } SpringAnimation { target: menuButtonIconBar1; properties: "rotation, scale"; spring: 3; damping: 0.25; epsilon: 0.5; mass: 1; modulus: 0; velocity: 0 } SpringAnimation { target: menuButtonIconBar2; properties: "rotation, scale"; spring: 3; damping: 0.25; epsilon: 0.5; mass: 1; modulus: 0; velocity: 0 } } ] }