QtWebEngine: Implement scroll.delta_page

This commit is contained in:
Florian Bruhin 2016-07-13 11:26:53 +02:00
parent 602d10c495
commit c83a8a64dc
2 changed files with 11 additions and 1 deletions

View File

@ -229,7 +229,11 @@ class WebEngineScroller(browsertab.AbstractScroller):
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)

View File

@ -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);
}