Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-17552

Changes to Animation's 'to' and 'from' properties ignored while animating

    XMLWordPrintable

Details

    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

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              brasser Michael Brasser (closed Nokia identity) (Inactive)
              mathiasm Mathias Malmqvist
              Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes