From 011b88a7b37680288944bde2c4769fd203ee8218 Mon Sep 17 00:00:00 2001 From: Alberto Mardegan Date: Sun, 18 Dec 2011 19:12:42 +0200 Subject: Compute overshoot condition before snap points Snap points are not needed if the overshoot condition is met; therefore, move the overshoot handling before the computation of snap points. Change-Id: I37556b10c1b1124eaed53b0f2a330085acf70776 Reviewed-by: Robin Burchell --- src/widgets/util/qscroller.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src/widgets/util') diff --git a/src/widgets/util/qscroller.cpp b/src/widgets/util/qscroller.cpp index e39ed9c0a5..2c8b617761 100644 --- a/src/widgets/util/qscroller.cpp +++ b/src/widgets/util/qscroller.cpp @@ -1293,6 +1293,16 @@ void QScrollerPrivate::createScrollingSegments(qreal v, qreal startPos, qScrollerDebug() << " Real Delta:" << deltaPos; + // -- check if are in overshoot and end in overshoot + if ((startPos < minPos && endPos < minPos) || + (startPos > maxPos && endPos > maxPos)) { + qreal stopPos = endPos < minPos ? minPos : maxPos; + qreal oDeltaTime = sp->overshootScrollTime; + + pushSegment(ScrollTypeOvershoot, oDeltaTime * qreal(0.7), qreal(1.0), startPos, stopPos - startPos, stopPos, sp->scrollingCurve.type(), orientation); + return; + } + // -- determine snap points qreal nextSnap = nextSnapPos(endPos, 0, orientation); qreal lowerSnapPos = nextSnapPos(startPos, -1, orientation); @@ -1306,16 +1316,6 @@ void QScrollerPrivate::createScrollingSegments(qreal v, qreal startPos, if (nextSnap < lowerSnapPos || qIsNaN(lowerSnapPos)) lowerSnapPos = nextSnap; - // -- check if are in overshoot and end in overshoot - if ((startPos < minPos && endPos < minPos) || - (startPos > maxPos && endPos > maxPos)) { - qreal stopPos = endPos < minPos ? minPos : maxPos; - qreal oDeltaTime = sp->overshootScrollTime; - - pushSegment(ScrollTypeOvershoot, oDeltaTime * qreal(0.7), qreal(1.0), startPos, stopPos - startPos, stopPos, sp->scrollingCurve.type(), orientation); - return; - } - if (qAbs(v) < sp->minimumVelocity) { qScrollerDebug() << "### below minimum Vel" << orientation; -- cgit v1.2.3