diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2017-04-27 11:11:49 +0200 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2017-05-22 19:14:00 +0000 |
commit | 057fc4b5b037284ffe299a28725fcf59c7ac066f (patch) | |
tree | 1d4188c5951796d92bc7be9120f2cbcd85310915 /tests/manual/pointer/content/FakeFlickable.qml | |
parent | aa1830fc1706a45e2b6721da85f6484fec821484 (diff) |
FakeFlickable: animate returnToBounds() when flicking is done
It looks much nicer than just jerking back into position.
We still don't have "resistance" to dragging past the bounds, though.
Change-Id: I60f6f58fe87638fd17144ea6640bae673a3b633d
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'tests/manual/pointer/content/FakeFlickable.qml')
-rw-r--r-- | tests/manual/pointer/content/FakeFlickable.qml | 49 |
1 files changed, 41 insertions, 8 deletions
diff --git a/tests/manual/pointer/content/FakeFlickable.qml b/tests/manual/pointer/content/FakeFlickable.qml index bfae653503..801b6b9f31 100644 --- a/tests/manual/pointer/content/FakeFlickable.qml +++ b/tests/manual/pointer/content/FakeFlickable.qml @@ -62,14 +62,23 @@ Item { property real ylimit: root.height - __contentItem.height function returnToBounds() { - if (x > 0) - x = 0 - else if (x < xlimit) - x = xlimit - if (y > 0) - y = 0 - else if (y < ylimit) - y = ylimit + var startAnim = false + if (x > 0) { + returnToBoundsAnim.x = 0 + startAnim = true + } else if (x < xlimit) { + returnToBoundsAnim.x = xlimit + startAnim = true + } + if (y > 0) { + returnToBoundsAnim.y = 0 + startAnim = true + } else if (y < ylimit) { + returnToBoundsAnim.y = ylimit + startAnim = true + } + if (startAnim) + returnToBoundsAnim.start() } DragHandler { @@ -85,5 +94,29 @@ Item { root.flickEnded() } } + ParallelAnimation { + id: returnToBoundsAnim + property Item target: __contentItem + property int duration: 200 + property real x: 0 + property real y: 0 + + NumberAnimation { + id: xAnim + target: returnToBoundsAnim.target + property: "x" + to: returnToBoundsAnim.x + duration: returnToBoundsAnim.duration + easing.type: Easing.OutQuad + } + NumberAnimation { + id: yAnim + target: returnToBoundsAnim.target + property: "y" + to: returnToBoundsAnim.y + duration: returnToBoundsAnim.duration + easing.type: Easing.OutQuad + } + } } } |