From 35d4eebbb0b4ce8439ac187a390f1f3b34099da6 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 9 Jun 2026 10:53:47 +0200 Subject: [PATCH] Bug 42799: Replace IntersectionObserver with scroll listener for sticky behaviour Assisted-by: Mistral Vibe Signed-off-by: Paul Derscheid Signed-off-by: Martin Renvoize Signed-off-by: Pedro Amorim --- .../intranet-tmpl/prog/js/staff-global.js | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js b/koha-tmpl/intranet-tmpl/prog/js/staff-global.js index 357372f059..f8dc555482 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js +++ b/koha-tmpl/intranet-tmpl/prog/js/staff-global.js @@ -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 () {