Warning, /webapps/qmlonline/qml/examples/anchoranimation.qml is written in an unsupported language. File is not indexed.

0001 import QtQuick 2.12
0002 
0003 Item {
0004     id: root
0005     anchors.fill: parent
0006 
0007     Rectangle {
0008         id: rect
0009         width: parent.width/6
0010         height: width
0011         color: "green"
0012     }
0013 
0014     states: [
0015         State {
0016             name: "right"
0017             AnchorChanges { target: rect; anchors.right: root.right }
0018         },
0019         State {
0020             name: "left"
0021             AnchorChanges { target: rect; anchors.left: root.left }
0022         }
0023     ]
0024 
0025     transitions: Transition {
0026         AnchorAnimation { duration: 500 }
0027     }
0028 
0029     Timer {
0030         running: true; repeat: true; interval: 1000
0031         onTriggered: root.state = root.state === "right" ? "left" : "right"
0032     }
0033 }