Ensure flickable velocity is updated when under heavy load.
authorMartin Jones <martin.jones@nokia.com>
Thu, 1 Dec 2011 01:48:59 +0000 (11:48 +1000)
committerQt by Nokia <qt-info@nokia.com>
Thu, 1 Dec 2011 02:51:25 +0000 (03:51 +0100)
If the Flickable is forced to move very quickly due to highlight motion
the smoothed velocity animation may not have an opportunity to run
before being reset, resulting in the velocity not being updated.  In this
case just set the velocity directly since the motion is driven by an
animation anyway.

Change-Id: I1e5e9396f4c1cd12e95c6ac47941dad25e4aa897
Reviewed-by: Andrew den Exter <andrew.den-exter@nokia.com>

src/declarative/items/qquickflickable.cpp

index 2f7b744..aca3542 100644 (file)
@@ -1177,13 +1177,19 @@ void QQuickFlickable::viewportMoved()
             qreal horizontalVelocity = (prevX - d->hData.move.value()) * 1000 / elapsed;
             if (qAbs(horizontalVelocity) > 0) {
                 d->velocityTimeline.reset(d->hData.smoothVelocity);
-                d->velocityTimeline.move(d->hData.smoothVelocity, horizontalVelocity, d->reportedVelocitySmoothing);
+                if (d->calcVelocity)
+                    d->velocityTimeline.set(d->hData.smoothVelocity, horizontalVelocity);
+                else
+                    d->velocityTimeline.move(d->hData.smoothVelocity, horizontalVelocity, d->reportedVelocitySmoothing);
                 d->velocityTimeline.move(d->hData.smoothVelocity, 0, d->reportedVelocitySmoothing);
             }
             qreal verticalVelocity = (prevY - d->vData.move.value()) * 1000 / elapsed;
             if (qAbs(verticalVelocity) > 0) {
                 d->velocityTimeline.reset(d->vData.smoothVelocity);
-                d->velocityTimeline.move(d->vData.smoothVelocity, verticalVelocity, d->reportedVelocitySmoothing);
+                if (d->calcVelocity)
+                    d->velocityTimeline.set(d->vData.smoothVelocity, verticalVelocity);
+                else
+                    d->velocityTimeline.move(d->vData.smoothVelocity, verticalVelocity, d->reportedVelocitySmoothing);
                 d->velocityTimeline.move(d->vData.smoothVelocity, 0, d->reportedVelocitySmoothing);
             }
         }