Details
-
Suggestion
-
Resolution: Duplicate
-
P3: Somewhat important
-
4.7.3
-
None
Description
Run the code below. The red rectangle will bounce between the left and right side of the blue rectangle. Click anywhere to resize the blue rectangle. Note that when the size change the red rectangle keeps animating according to the blue rectangle's original size. I.e. the animation keeps animating according to the to and from values as they were when the animation started, and are not updated when the values they bind to changes. Only restarting the SequentialAnimation will update the animation's values, making the animation jump back to it's starting point.
import QtQuick 1.1 Item { width: 950 height: 500 Rectangle { id: blueRect color: "blue" width: 500; height: 300 Rectangle { id: redRect color: "red" width: 50 height: 50 anchors.verticalCenter: parent.verticalCenter } SequentialAnimation { id: anim running: true loops: Animation.Infinite NumberAnimation { target: redRect; property: "x" from: 0; to: blueRect.width-redRect.width duration: 1000 } NumberAnimation { target: redRect; property: "x" from: blueRect.width-redRect.width; to: 0 onFromChanged: print("new from value: " + from) duration: 1000 } } } MouseArea { anchors.fill: parent onClicked: { blueRect.width = mouse.x; blueRect.height = mouse.y; // anim.restart(); } } }
Attachments
Issue Links
- is replaced by
-
QTBUG-13268 Bindings in transitions not evaluated (from property in animation)
-
- Open
-
- relates to
-
QTBUG-38932 PropertyAnimation ignores from/to changes
-
- Closed
-
-
QTBUG-64580 NumberAnimation properties not re-evaluated in consecutive runs of the animation
-
- Reported
-