diff options
author | Robert Griebl <rgriebl@trolltech.com> | 2010-04-14 18:41:18 +0200 |
---|---|---|
committer | Robert Griebl <rgriebl@trolltech.com> | 2010-04-14 18:41:18 +0200 |
commit | 048d94bf93f5199054a39a5b7920960d533a7c4b (patch) | |
tree | 2e2ea7ada2261c8b6c458510908523f6760912ef | |
parent | 28bd34d57fd99d0f90b6cb59ca8a0d4ad8ebb572 (diff) |
better velocity calculation
-rw-r--r-- | qkineticscroller.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/qkineticscroller.cpp b/qkineticscroller.cpp index d06f7eb..d963d82 100644 --- a/qkineticscroller.cpp +++ b/qkineticscroller.cpp @@ -767,7 +767,9 @@ void QKineticScrollerPrivate::timerEventWhileScrolling() qreal deltaTime = qreal(scrollRelativeTimer.restart()) / 1000; qreal time = qreal(scrollAbsoluteTimer.elapsed()) / 1000; - QPointF newVelocity = calculateVelocity(time); + // calculate the velocity for the passed interval deltatime. + // using the midpoint of the interval gives a better precision than using just time. + QPointF newVelocity = calculateVelocity(time - deltaTime / 2); QPointF deltaPos = newVelocity * deltaTime * pixelPerMeter; // -- move (convert from [m/s] to [pix/frame] |