diff options
author | Daniel Carl <danielcarl@gmx.de> | 2023-01-05 13:18:10 +0100 |
---|---|---|
committer | Rafael Marçalo <raroma09@gmail.com> | 2023-01-17 20:19:30 +0000 |
commit | a012a0349a491b15541f74af4efd555fc221895f (patch) | |
tree | fa4298bc616ff2ba4ce6d9cb481af34bc174670f | |
parent | ba53913906e1127b775d910db907bbcd9838951a (diff) |
Fix possible wrong dimension use for scrolling #723.
The body.scrollHeigh is sometimes 0 so it was not possible to scroll to
the end of document. So this patch used a more sophisticated approach to
get the overall document height.
-rw-r--r-- | src/scripts/scroll.js | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/scripts/scroll.js b/src/scripts/scroll.js index c23e2f2..5df9030 100644 --- a/src/scripts/scroll.js +++ b/src/scripts/scroll.js @@ -3,6 +3,7 @@ function vbscroll(mode, scrollStep, count) { d = document, x = y = 0, ph = w.innerHeight, + de = d.documentElement, c = count||1, rel = true; switch (mode) { @@ -34,9 +35,15 @@ function vbscroll(mode, scrollStep, count) { case 'g': x = w.scrollX; if (count) { - y = c * ((d.documentElement.scrollHeight - w.innerHeight) / 100); + y = c * ((d.documentElement.scrollHeight - ph) / 100); } else { - y = 'G' == mode ? d.body.scrollHeight : 0; + y = 'G' == mode + ? Math.max( + d.body.scrollHeight, de.scrollHeight, + d.body.offsetHeight, de.offsetHeight, + d.body.clientHeight, de.clientHeight + ) + : 0; } rel = false; break; |