From d76c52133160f4394df2d6dc4d239c54833c1ab3 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Wed, 2 Sep 2009 11:27:10 +1000 Subject: Fix animation-after-zooming problem. Ensures final viewport XY is set and that setting it always clears animations (even if the position is coincidentally unchanged). Case is changing width/height twice - once too small, then large enough again, first change starts correction animation, which must be stopped by second change. --- demos/declarative/webbrowser/webbrowser.qml | 29 +++++++++++++++++++++++------ src/declarative/fx/qfxflickable.cpp | 4 ++-- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/demos/declarative/webbrowser/webbrowser.qml b/demos/declarative/webbrowser/webbrowser.qml index 4c4ad7c..6217019 100644 --- a/demos/declarative/webbrowser/webbrowser.qml +++ b/demos/declarative/webbrowser/webbrowser.qml @@ -215,14 +215,14 @@ Item { property: "scale" from: 1 to: 0 // set before calling - easing: "easeInOutQuad" + easing: "easeLinear" duration: 200 } NumberAnimation { id: FlickVX target: Flick property: "viewportX" - easing: "easeInOutQuad" + easing: "easeLinear" duration: 200 from: 0 // set before calling to: 0 // set before calling @@ -231,21 +231,36 @@ Item { id: FlickVY target: Flick property: "viewportY" - easing: "easeInOutQuad" + easing: "easeLinear" duration: 200 from: 0 // set before calling to: 0 // set before calling } } PropertyAction { + id: FinalZoom + target: MyWebView + property: "zoomFactor" + } + PropertyAction { target: MyWebView property: "scale" value: 1.0 } + // Have to set the viewportXY, since the above 2 + // size changes may have started a correction if + // zoomFactor < 1.0. PropertyAction { - id: FinalZoom - target: MyWebView - property: "zoomFactor" + id: FinalX + target: Flick + property: "viewportX" + value: 0 // set before calling + } + PropertyAction { + id: FinalY + target: Flick + property: "viewportY" + value: 0 // set before calling } PropertyAction { target: MyWebView @@ -259,8 +274,10 @@ Item { ScaleAnim.to = sc; FlickVX.from = Flick.viewportX FlickVX.to = Math.min(Math.max(0,centerX-Flick.width/2),MyWebView.width*sc-Flick.width) + FinalX.value = Math.min(Math.max(0,centerX-Flick.width/2),MyWebView.width*sc-Flick.width) FlickVY.from = Flick.viewportY FlickVY.to = Math.min(Math.max(0,centerY-Flick.height/2),MyWebView.height*sc-Flick.height) + FinalY.value = Math.min(Math.max(0,centerY-Flick.height/2),MyWebView.height*sc-Flick.height) FinalZoom.value = zoom QuickZoom.start() } diff --git a/src/declarative/fx/qfxflickable.cpp b/src/declarative/fx/qfxflickable.cpp index 27bfa27..118658f 100644 --- a/src/declarative/fx/qfxflickable.cpp +++ b/src/declarative/fx/qfxflickable.cpp @@ -386,8 +386,8 @@ void QFxFlickable::setViewportX(qreal pos) { Q_D(QFxFlickable); pos = qRound(pos); + d->_tl.reset(d->_moveX); if (-pos != d->_moveX.value()) { - d->_tl.reset(d->_moveX); d->_moveX.setValue(-pos); viewportMoved(); } @@ -403,8 +403,8 @@ void QFxFlickable::setViewportY(qreal pos) { Q_D(QFxFlickable); pos = qRound(pos); + d->_tl.reset(d->_moveY); if (-pos != d->_moveY.value()) { - d->_tl.reset(d->_moveY); d->_moveY.setValue(-pos); viewportMoved(); } -- cgit v0.12