Fix axis locking for AutoFlickDirection
authorAndras Becsi <andras.becsi@nokia.com>
Thu, 10 May 2012 13:12:18 +0000 (15:12 +0200)
committerQt by Nokia <qt-info@nokia.com>
Fri, 11 May 2012 09:46:25 +0000 (11:46 +0200)
If the flickableDirection property is AutoFlickDirection Flickable
compares qreals for equality to decide whether to lock flicking in one
direction. This is too restrictive since the content size could have
rounding errors withing the one pixel range resulting from pixel
alignment and float calculations.

Flickable should consider the content width/height equal to its
width/height if their difference is within the one pixel range.

Change-Id: Id3bff33d6f798860c62c699a6c2795213efe233d
Reviewed-by: Martin Jones <martin.jones@nokia.com>
src/quick/items/qquickflickable.cpp

index dcb484c..1f7c800 100644 (file)
@@ -1763,7 +1763,7 @@ bool QQuickFlickable::xflick() const
 {
     Q_D(const QQuickFlickable);
     if (d->flickableDirection == QQuickFlickable::AutoFlickDirection)
-        return vWidth() != width();
+        return floor(qAbs(vWidth() - width()));
     return d->flickableDirection & QQuickFlickable::HorizontalFlick;
 }
 
@@ -1771,7 +1771,7 @@ bool QQuickFlickable::yflick() const
 {
     Q_D(const QQuickFlickable);
     if (d->flickableDirection == QQuickFlickable::AutoFlickDirection)
-        return vHeight() !=  height();
+        return floor(qAbs(vHeight() - height()));
     return d->flickableDirection & QQuickFlickable::VerticalFlick;
 }