##// END OF EJS Templates
accurate speed calculation to kinetic scrolling
sauimone -
r2190:2e3db467e0a5
parent child
Show More
@@ -63,8 +63,12 void Scroller::release(const QPointF &delta)
63 63
64 64 if ((m_timeStamp.elapsed() > m_timeTresholdMin) && (m_timeStamp.msecsTo(QTime::currentTime()) < m_timeTresholdMax)) {
65 65 // Release was quick enough. Start scrolling.
66 // Magic number is to make scroll bit slower (the resolution of screen may affect this)
67 m_speed = delta / 5;
66 qreal interval = 25;
67 qreal time = m_timeStamp.msecsTo(QTime::currentTime());
68 if (qFuzzyIsNull(time))
69 m_speed = delta / 5;
70 else
71 m_speed = delta * interval / time;
68 72
69 73 qreal fraction = qMax(qAbs(m_speed.x()), qAbs(m_speed.y()));
70 74
@@ -75,7 +79,7 void Scroller::release(const QPointF &delta)
75 79 m_fraction.setX(1);
76 80 m_fraction.setY(1);
77 81 }
78 startTicker(25);
82 startTicker(interval);
79 83 m_state = Scroll;
80 84 } else {
81 85 stopTicker(); // Stop ticker, if one is running.
General Comments 0
You need to be logged in to leave comments. Login now