1
0
forked from w0bm/f0bm

REAL seamless now!

This commit is contained in:
eins
2026-01-23 15:53:45 +00:00
parent 9b1041dda7
commit 964284d5c9

View File

@@ -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 {
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();
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";
}
}
});
}