diff options
author | J-P Nurmi <jpnurmi@qt.io> | 2016-09-01 13:23:47 +0200 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2016-09-02 13:07:30 +0000 |
commit | dac19e5054c354752f4da8e1ec33cccde16a699b (patch) | |
tree | 7a1b9c4eeca971ae75b66c20086e9cd2606f110d /src/quicktemplates2/qquickdrawer.cpp | |
parent | d00c6d93ce1974e27bb49c57ae87156260501577 (diff) |
QQuickDrawer: fix velocity calculation
Use the vertical velocity for top and bottom edges, and invert
the speed for right and bottom edges.
Change-Id: I362dda23f0a2cda60ad7cd52e7373d0707feea83
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/quicktemplates2/qquickdrawer.cpp')
-rw-r--r-- | src/quicktemplates2/qquickdrawer.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/quicktemplates2/qquickdrawer.cpp b/src/quicktemplates2/qquickdrawer.cpp index b5bebd9b..d11a8bdf 100644 --- a/src/quicktemplates2/qquickdrawer.cpp +++ b/src/quicktemplates2/qquickdrawer.cpp @@ -285,7 +285,23 @@ bool QQuickDrawerPrivate::handleMouseReleaseEvent(QQuickItem *item, QMouseEvent if (wasGrabbed) { const QPointF releasePoint = event->windowPos(); velocityCalculator.stopMeasuring(releasePoint, event->timestamp()); - const qreal velocity = velocityCalculator.velocity().x(); + + qreal velocity = 0; + if (edge == Qt::LeftEdge || edge == Qt::RightEdge) + velocity = velocityCalculator.velocity().x(); + else + velocity = velocityCalculator.velocity().y(); + + // the velocity is calculated so that swipes from left to right + // and top to bottom have positive velocity, and swipes from right + // to left and bottom to top have negative velocity. + // + // - top/left edge: positive velocity opens, negative velocity closes + // - bottom/right edge: negative velocity opens, positive velocity closes + // + // => invert the velocity for bottom and right edges, for the threshold comparison below + if (edge == Qt::RightEdge || edge == Qt::BottomEdge) + velocity = -velocity; if (position > 0.7 || velocity > openCloseVelocityThreshold) { transitionManager.transitionEnter(); |