diff options
Diffstat (limited to 'tests/manual/pointer/flingAnimation.qml')
-rw-r--r-- | tests/manual/pointer/flingAnimation.qml | 60 |
1 files changed, 57 insertions, 3 deletions
diff --git a/tests/manual/pointer/flingAnimation.qml b/tests/manual/pointer/flingAnimation.qml index 851ffd1083..3b0d359530 100644 --- a/tests/manual/pointer/flingAnimation.qml +++ b/tests/manual/pointer/flingAnimation.qml @@ -43,15 +43,48 @@ Rectangle { id: ball objectName: "ball" + index source: "resources/redball.png" - width: 80; height: 80; x: 200 + index * 200; y: 200 + property real homeX: 200 + index * 200 + property real homeY: 200 + width: 80; height: 80; x: homeX; y: 200 Text { anchors.centerIn: parent color: "white" - text: anim.velocity.x.toFixed(2) + "," + anim.velocity.y.toFixed(2) + text: momentum.velocity.x.toFixed(2) + "," + momentum.velocity.y.toFixed(2) } - MomentumAnimation { id: anim; target: ball } + SequentialAnimation { + id: anim + + function restart(vel) { + stop() + momentum.velocity = vel + start() + } + + MomentumAnimation { id: momentum; target: ball } + + PauseAnimation { duration: 500 } + + ParallelAnimation { + id: ballReturn + NumberAnimation { + target: ball + property: "x" + to: homeX + duration: 1000 + easing.period: 50 + easing.type: Easing.OutElastic + } + NumberAnimation { + target: ball + property: "y" + to: homeY + duration: 1000 + easing.type: Easing.OutElastic + } + } + } DragHandler { id: dragHandler @@ -68,6 +101,27 @@ Rectangle { radius: width / 2 opacity: 0.25 } + + Rectangle { + visible: width > 0 + width: dragHandler.point.velocity.length() * 100 + height: 2 + x: ball.width / 2 + y: ball.height / 2 + z: -1 + rotation: Math.atan2(dragHandler.point.velocity.y, dragHandler.point.velocity.x) * 180 / Math.PI + transformOrigin: Item.BottomLeft + antialiasing: true + + Image { + source: "resources/arrowhead.png" + anchors.right: parent.right + anchors.verticalCenter: parent.verticalCenter + width: 16 + height: 12 + antialiasing: true + } + } } } } |