From e33254315fab5fa67c53e2c860d41fe751c5a4ff Mon Sep 17 00:00:00 2001 From: Ralf Engels Date: Wed, 14 Apr 2010 18:49:02 +0200 Subject: Fix bugs --- qkineticscroller.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/qkineticscroller.cpp b/qkineticscroller.cpp index d963d82..f2888a4 100644 --- a/qkineticscroller.cpp +++ b/qkineticscroller.cpp @@ -932,6 +932,8 @@ void QKineticScroller::scrollTo(const QPointF &pos, int scrollTime) d->scrollToX = true; d->scrollToY = true; d->releaseVelocity = v; + d->scrollRelativeTimer.restart(); + d->scrollAbsoluteTimer.restart(); d->setState(QKineticScroller::StateScrolling); } @@ -1005,16 +1007,20 @@ void QKineticScrollerPrivate::setContentPositionHelper(const QPointF &deltaPos) // --- handle overshooting and stop if the coordinate is going back inside the normal area bool alwaysOvershoot = (overshootPolicy == QKineticScroller::OvershootAlwaysOn); - - qreal oldOvershootX = (maxPos.x() || alwaysOvershoot) ? oldPos.x() - oldClampedPos.x() : 0; - qreal oldOvershootY = (maxPos.y() || alwaysOvershoot) ? oldPos.y() - oldClampedPos.y() : 0; - if (state == QKineticScroller::StateDragging) { + bool noOvershoot = (overshootPolicy == QKineticScroller::OvershootAlwaysOff) || + ((state == QKineticScroller::StateDragging) && !overshootDragResistanceFactor); + bool canOvershootX = !noOvershoot && (alwaysOvershoot || maxPos.x()); + bool canOvershootY = !noOvershoot && (alwaysOvershoot || maxPos.y()); + + qreal oldOvershootX = (canOvershootX) ? oldPos.x() - oldClampedPos.x() : 0; + qreal oldOvershootY = (canOvershootY) ? oldPos.y() - oldClampedPos.y() : 0; + if (state == QKineticScroller::StateDragging && overshootDragResistanceFactor) { oldOvershootX /= overshootDragResistanceFactor; oldOvershootY /= overshootDragResistanceFactor; } - qreal newOvershootX = (maxPos.x() || alwaysOvershoot) ? newPos.x() - newClampedPos.x() : 0; - qreal newOvershootY = (maxPos.y() || alwaysOvershoot) ? newPos.y() - newClampedPos.y() : 0; + qreal newOvershootX = (canOvershootX) ? newPos.x() - newClampedPos.x() : 0; + qreal newOvershootY = (canOvershootY) ? newPos.y() - newClampedPos.y() : 0; // --- sanity check for scrollTo in case we can't even scroll that direction if (!(maxPos.x() || alwaysOvershoot)) -- cgit v1.2.3