diff options
author | Yoann Laissus <yoann.laissus@gmail.com> | 2010-08-25 17:00:32 +0200 |
---|---|---|
committer | Yoann Laissus <yoann.laissus@gmail.com> | 2010-08-25 17:00:32 +0200 |
commit | 7b3a9dfa506d1d60e140dbf0be62ac96e1a852c3 (patch) | |
tree | cf56d7e00173af6b8dd4c58ab625cd5a4fe7a431 /src | |
parent | Restore mr #174. (diff) | |
download | rekonq-7b3a9dfa506d1d60e140dbf0be62ac96e1a852c3.tar.xz |
Finally fix the smooth scrolling distance per scroll
Diffstat (limited to 'src')
-rw-r--r-- | src/webview.cpp | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/webview.cpp b/src/webview.cpp index 1ffb2f1e..d911bc3a 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -540,8 +540,9 @@ void WebView::keyPressEvent(QKeyEvent *event) void WebView::wheelEvent(QWheelEvent *event) { // To let some websites (eg: google maps) to handle wheel events - int ypos = page()->currentFrame()->scrollPosition().y(); + int prevPos = page()->currentFrame()->scrollPosition().y(); KWebView::wheelEvent(event); + int newPos = page()->currentFrame()->scrollPosition().y(); // Sync with the zoom slider if (event->modifiers() == Qt::ControlModifier) @@ -559,23 +560,21 @@ void WebView::wheelEvent(QWheelEvent *event) emit zoomChanged(newFactor); } - else if (ReKonfig::smoothScrolling() && ypos != page()->currentFrame()->scrollPosition().y()) + else if (ReKonfig::smoothScrolling() && prevPos != newPos) { - page()->currentFrame()->setScrollPosition(QPoint(page()->currentFrame()->scrollPosition().x(), ypos)); - int numDegrees = event->delta() / 8; - int numSteps = numDegrees / 15; + page()->currentFrame()->setScrollPosition(QPoint(page()->currentFrame()->scrollPosition().x(), prevPos)); - if ((numSteps > 0) != !_scrollBottom) + if ((event->delta() > 0) != !_scrollBottom) stopScrolling(); - if (numSteps > 0) + if (event->delta() > 0) _scrollBottom = false; else _scrollBottom = true; - setupSmoothScrolling(QApplication::wheelScrollLines() * abs(numSteps) * 20); + setupSmoothScrolling(abs(newPos - prevPos)); } } |