scroll.js: Use window.inner{Width,Height}
It seems with document.documentElement.client{Height,Width} we sometimes (e.g. without <!DOCTYPE html)...) get the full element height instead of the viewport height. Fixes #1821.
This commit is contained in:
parent
aafdc225bc
commit
a23f3a24b3
@ -28,23 +28,23 @@ window._qutebrowser.scroll = (function() {
|
||||
var y_px = window.scrollY;
|
||||
|
||||
if (x !== undefined) {
|
||||
x_px = (elem.scrollWidth - elem.clientWidth) / 100 * x;
|
||||
x_px = (elem.scrollWidth - window.innerWidth) / 100 * x;
|
||||
}
|
||||
|
||||
if (y !== undefined) {
|
||||
y_px = (elem.scrollHeight - elem.clientHeight) / 100 * y;
|
||||
y_px = (elem.scrollHeight - window.innerHeight) / 100 * y;
|
||||
}
|
||||
|
||||
/*
|
||||
console.log(JSON.stringify({
|
||||
"x": x,
|
||||
"window.scrollX": window.scrollX,
|
||||
"elem.clientWidth": elem.clientWidth,
|
||||
"window.innerWidth": window.innerWidth,
|
||||
"elem.scrollWidth": elem.scrollWidth,
|
||||
"x_px": x_px,
|
||||
"y": y,
|
||||
"window.scrollY": window.scrollY,
|
||||
"elem.clientHeight": elem.clientHeight,
|
||||
"window.innerHeight": window.innerHeight,
|
||||
"elem.scrollHeight": elem.scrollHeight,
|
||||
"y_px": y_px,
|
||||
}));
|
||||
@ -54,15 +54,15 @@ window._qutebrowser.scroll = (function() {
|
||||
};
|
||||
|
||||
funcs.delta_page = function(x, y) {
|
||||
var dx = document.documentElement.clientWidth * x;
|
||||
var dy = document.documentElement.clientHeight * y;
|
||||
var dx = window.innerWidth * x;
|
||||
var dy = window.innerHeight * y;
|
||||
window.scrollBy(dx, dy);
|
||||
};
|
||||
|
||||
funcs.pos = function() {
|
||||
var elem = document.documentElement;
|
||||
var dx = elem.scrollWidth - elem.clientWidth;
|
||||
var dy = elem.scrollHeight - elem.clientHeight;
|
||||
var dx = elem.scrollWidth - window.innerWidth;
|
||||
var dy = elem.scrollHeight - window.innerHeight;
|
||||
var perc_x, perc_y;
|
||||
|
||||
if (dx === 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user