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 <html> 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.
This commit is contained in:
renaud gaudin 2022-01-03 14:41:19 +00:00
parent a8577d7a01
commit b1bc883bf5
1 changed files with 1 additions and 1 deletions

View File

@ -345,7 +345,7 @@
}); });
async function loadSubset() { async function loadSubset() {
if (window.innerHeight + window.scrollY >= document.body.offsetHeight) { if (window.innerHeight + window.scrollY >= (document.body.offsetHeight * 0.98)) {
if (incrementalLoadingParams.count) { if (incrementalLoadingParams.count) {
loadAndDisplayBooks(); loadAndDisplayBooks();
} }