diff --git a/src/controls/QskPanGestureRecognizer.cpp b/src/controls/QskPanGestureRecognizer.cpp index 9a24342b..feef964d 100644 --- a/src/controls/QskPanGestureRecognizer.cpp +++ b/src/controls/QskPanGestureRecognizer.cpp @@ -7,6 +7,26 @@ #include #include +static inline bool qskIsInOrientation( + const QPointF& from, const QPointF& to, Qt::Orientations orientations ) +{ + if ( orientations == ( Qt::Horizontal | Qt::Vertical ) ) + return true; + + const qreal dx = std::fabs( to.x() - from.x() ); + const qreal dy = std::fabs( to.y() - from.y() ); + + const qreal ratio = 0.75; + + if ( orientations == Qt::Horizontal ) + return ( dx >= ratio * dy ); + + if ( orientations == Qt::Vertical ) + return ( dy >= ratio * dx ); + + return false; // should never happen +} + static inline qreal qskDistance( const QPointF& from, const QPointF& to, Qt::Orientations orientations ) { @@ -202,7 +222,8 @@ void QskPanGestureRecognizer::moveEvent( const QMouseEvent* event ) const qreal dist = qskDistance( m_data->origin, m_data->pos, m_data->orientations ); - if ( ( dist >= m_data->minDistance ) || ( -dist >= m_data->minDistance ) ) + if ( ( qAbs( dist ) >= m_data->minDistance ) && + qskIsInOrientation( m_data->origin, m_data->pos, m_data->orientations ) ) { accept(); started = true;