Bug 42799: Replace IntersectionObserver with scroll listener for sticky behaviour

Assisted-by: Mistral Vibe <vibe@mistral.ai>
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Pedro Amorim <pedro.amorim@openfifth.co.uk>
This commit is contained in:
Jonathan Druart 2026-06-09 10:53:47 +02:00 committed by Pedro Amorim
parent 74b820394d
commit 35d4eebbb0
No known key found for this signature in database
GPG Key ID: 06B75BA7F3894D55
1 changed files with 6 additions and 13 deletions

View File

@ -78,20 +78,13 @@ function togglePanel(node) {
function apply_sticky(node) {
if (!node) return;
let sentinel = node.previousElementSibling;
const onScroll = () => {
const rect = node.getBoundingClientRect();
node.classList.toggle("floating", rect.top <= 0);
};
if (!sentinel || !sentinel.classList.contains("sticky-sentinel")) {
sentinel = document.createElement("div");
sentinel.className = "sticky-sentinel";
node.parentNode.insertBefore(sentinel, node);
}
const observer = new IntersectionObserver(([entry]) => {
node.classList.toggle("floating", !entry.isIntersecting);
});
observer.observe(sentinel);
window.addEventListener("scroll", onScroll, { passive: true });
onScroll();
}
$(document).ready(function () {