diff options
author | Martin Jones <martin.jones@nokia.com> | 2010-08-26 03:51:38 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2010-08-26 03:51:38 (GMT) |
commit | d630c627ed1dfbcfb48f907d2d37048b049830a5 (patch) | |
tree | 5f8d95bfd38341f7ea86f625aedac3ec60cc59c3 | |
parent | 9afe3a12515b7c33ebc88832daf15c06f5d30e2c (diff) | |
download | Qt-d630c627ed1dfbcfb48f907d2d37048b049830a5.zip Qt-d630c627ed1dfbcfb48f907d2d37048b049830a5.tar.gz Qt-d630c627ed1dfbcfb48f907d2d37048b049830a5.tar.bz2 |
Avoid Flickable view jumping when drag threashold is exceeded.
Task-number: QTBUG-13176
-rw-r--r-- | src/declarative/graphicsitems/qdeclarativeflickable.cpp | 10 | ||||
-rw-r--r-- | src/declarative/graphicsitems/qdeclarativeflickable_p_p.h | 1 |
2 files changed, 9 insertions, 2 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativeflickable.cpp b/src/declarative/graphicsitems/qdeclarativeflickable.cpp index a6e8c85..a710190 100644 --- a/src/declarative/graphicsitems/qdeclarativeflickable.cpp +++ b/src/declarative/graphicsitems/qdeclarativeflickable.cpp @@ -653,6 +653,8 @@ void QDeclarativeFlickablePrivate::handleMousePressEvent(QGraphicsSceneMouseEven timeline.clear(); hData.velocity = 0; vData.velocity = 0; + hData.dragStartOffset = 0; + vData.dragStartOffset = 0; lastPos = QPoint(); QDeclarativeItemPrivate::start(lastPosTime); pressPos = event->pos(); @@ -675,7 +677,9 @@ void QDeclarativeFlickablePrivate::handleMouseMoveEvent(QGraphicsSceneMouseEvent if (q->yflick()) { int dy = int(event->pos().y() - pressPos.y()); if (qAbs(dy) > QApplication::startDragDistance() || QDeclarativeItemPrivate::elapsed(pressTime) > 200) { - qreal newY = dy + vData.pressPos; + if (!vMoved) + vData.dragStartOffset = dy; + qreal newY = dy + vData.pressPos - vData.dragStartOffset; const qreal minY = q->minYExtent(); const qreal maxY = q->maxYExtent(); if (newY > minY) @@ -705,7 +709,9 @@ void QDeclarativeFlickablePrivate::handleMouseMoveEvent(QGraphicsSceneMouseEvent if (q->xflick()) { int dx = int(event->pos().x() - pressPos.x()); if (qAbs(dx) > QApplication::startDragDistance() || QDeclarativeItemPrivate::elapsed(pressTime) > 200) { - qreal newX = dx + hData.pressPos; + if (!hMoved) + hData.dragStartOffset = dx; + qreal newX = dx + hData.pressPos - hData.dragStartOffset; const qreal minX = q->minXExtent(); const qreal maxX = q->maxXExtent(); if (newX > minX) diff --git a/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h b/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h index b919e1b..c398faa 100644 --- a/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h +++ b/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h @@ -96,6 +96,7 @@ public: QDeclarativeTimeLineValueProxy<QDeclarativeFlickablePrivate> move; qreal viewSize; qreal pressPos; + qreal dragStartOffset; qreal velocity; qreal flickTarget; QDeclarativeFlickablePrivate::Velocity smoothVelocity; |