Permalink
Browse files

QtWebEngine: Implement scroll.delta_page

  • Loading branch information...
The-Compiler committed Jul 13, 2016
1 parent 602d10c commit c83a8a64dcb56e9b47aff4473a6e273b9ca7ca74
Showing with 11 additions and 1 deletion.
  1. +5 −1 qutebrowser/browser/webengine/webenginetab.py
  2. +6 −0 qutebrowser/javascript/scroll.js
@@ -229,7 +229,11 @@ def delta(self, x=0, y=0):
self._tab.run_js_async("window.scrollBy({x}, {y});".format(x=x, y=y))
def delta_page(self, x=0, y=0):
- log.stub()
+ js_code = """
+ {scroll_js}
+ scroll_delta_page({x}, {y});
+ """.format(scroll_js=utils.read_file('javascript/scroll.js'), x=x, y=y)
+ self._tab.run_js_async(js_code)
def up(self, count=1):
self._key_press(Qt.Key_Up, count)
@@ -32,3 +32,9 @@ function scroll_to_perc(x, y) {
window.scroll(x_px, y_px);
}
+
+function scroll_delta_page(x, y) {
+ var dx = document.documentElement.clientWidth * x;
+ var dy = document.documentElement.clientHeight * y;
+ window.scrollBy(dx, dy);
+}

0 comments on commit c83a8a6

Please sign in to comment.