From 4407ef032af44f13e9724ab20483288962abec75 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Mon, 3 Oct 2016 07:01:22 +0200 Subject: [PATCH] Clean up JS --- qutebrowser/javascript/scroll.js | 33 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/qutebrowser/javascript/scroll.js b/qutebrowser/javascript/scroll.js index aad6917ca..ac19d175c 100644 --- a/qutebrowser/javascript/scroll.js +++ b/qutebrowser/javascript/scroll.js @@ -23,20 +23,20 @@ window._qutebrowser.scroll = (function() { var funcs = {}; funcs.to_perc = function(x, y) { - var elem = document.documentElement; var x_px = window.scrollX; var y_px = window.scrollY; + var width = Math.max( document.body.scrollWidth, document.body.offsetWidth, - elem.scrollWidth, - elem.offsetWidth + document.documentElement.scrollWidth, + document.documentElement.offsetWidth ); var height = Math.max( document.body.scrollHeight, document.body.offsetHeight, - elem.scrollHeight, - elem.offsetHeight + document.documentElement.scrollHeight, + document.documentElement.offsetHeight ); if (x !== undefined) { @@ -52,12 +52,12 @@ window._qutebrowser.scroll = (function() { "x": x, "window.scrollX": window.scrollX, "window.innerWidth": window.innerWidth, - "elem.scrollWidth": elem.scrollWidth, + "elem.scrollWidth": document.documentElement.scrollWidth, "x_px": x_px, "y": y, "window.scrollY": window.scrollY, "window.innerHeight": window.innerHeight, - "elem.scrollHeight": elem.scrollHeight, + "elem.scrollHeight": document.documentElement.scrollHeight, "y_px": y_px, })); */ @@ -72,23 +72,20 @@ window._qutebrowser.scroll = (function() { }; funcs.pos = function() { - var elem = document.documentElement; - var body = document.body; - var pos = { "px": {"x": window.scrollX, "y": window.scrollY}, "scroll": { "width": Math.max( - body.scrollWidth, - body.offsetWidth, - elem.scrollWidth, - elem.offsetWidth + document.body.scrollWidth, + document.body.offsetWidth, + document.documentElement.scrollWidth, + document.documentElement.offsetWidth ), "height": Math.max( - body.scrollHeight, - body.offsetHeight, - elem.scrollHeight, - elem.offsetHeight + document.body.scrollHeight, + document.body.offsetHeight, + document.documentElement.scrollHeight, + document.documentElement.offsetHeight ), }, "inner": {