From b1bc883bf5b8955491d257e97837322521eccd16 Mon Sep 17 00:00:00 2001 From: renaud gaudin Date: Mon, 3 Jan 2022 14:41:19 +0000 Subject: [PATCH] Fixed #603: safer scroll bound detection At least on Retina Macbook Pros but most likely on other configurations, the viewport's sizes is not exactly consistent to integer. For instance, on a maximized Firefox, document.body.offsetHeight is 1,600. When looking at the on the inspector, I'd get 1,599.6, so **roughly** the same but not exactly. Those inconsistencies are present on every level so being too strict about those is probably not adequate. This fixes #603 but allowing a 2% margin on the scroll position to match the _end of screen_ and thus trigger the loading of additional cards. This means that for the example above, it triggers at 1,568 instead of never reaching 1,600. 2% might be too large but it seems safe considering the potential of various resolutions we may encounter and I don't see any side effect. --- static/skin/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static/skin/index.js b/static/skin/index.js index 24e24bba1..eb1388997 100644 --- a/static/skin/index.js +++ b/static/skin/index.js @@ -345,7 +345,7 @@ }); async function loadSubset() { - if (window.innerHeight + window.scrollY >= document.body.offsetHeight) { + if (window.innerHeight + window.scrollY >= (document.body.offsetHeight * 0.98)) { if (incrementalLoadingParams.count) { loadAndDisplayBooks(); }