REAL seamless now!
This commit is contained in:
@@ -440,38 +440,19 @@ window.requestAnimFrame = (function () {
|
||||
}
|
||||
};
|
||||
|
||||
// Scroll detection
|
||||
let tts = 0;
|
||||
const scroll_treshold = 1;
|
||||
// Scroll detection - preload before reaching bottom
|
||||
const PRELOAD_OFFSET = 500; // pixels before bottom to trigger load
|
||||
|
||||
document.addEventListener("wheel", e => {
|
||||
window.addEventListener("scroll", () => {
|
||||
if (!document.querySelector('#main')) return;
|
||||
|
||||
if (Math.ceil(window.innerHeight + window.scrollY) >= document.querySelector('#main').offsetHeight && e.deltaY > 0) {
|
||||
// Scrolling down at bottom
|
||||
if (infiniteState.hasMore && !infiniteState.loading) {
|
||||
if (tts < scroll_treshold) {
|
||||
const foot = document.querySelector("div#footbar");
|
||||
if (foot) {
|
||||
foot.style.boxShadow = "inset 0px 4px 0px var(--footbar-color)";
|
||||
foot.style.color = "var(--footbar-color)";
|
||||
}
|
||||
tts++;
|
||||
} else {
|
||||
loadMoreItems();
|
||||
tts = 0;
|
||||
}
|
||||
}
|
||||
} else if (window.scrollY <= 0 && e.deltaY < 0) {
|
||||
// Scrolling up at top - could load previous page if needed (optional)
|
||||
tts = 0;
|
||||
} else {
|
||||
tts = 0;
|
||||
const foot = document.querySelector("div#footbar");
|
||||
if (foot) {
|
||||
foot.style.boxShadow = "unset";
|
||||
foot.style.color = "transparent";
|
||||
}
|
||||
const scrollPosition = window.innerHeight + window.scrollY;
|
||||
const pageHeight = document.querySelector('#main').offsetHeight;
|
||||
const distanceFromBottom = pageHeight - scrollPosition;
|
||||
|
||||
// Load more when within PRELOAD_OFFSET pixels of bottom
|
||||
if (distanceFromBottom < PRELOAD_OFFSET && infiniteState.hasMore && !infiniteState.loading) {
|
||||
loadMoreItems();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user