From d6fc7b07c1d3fd208f8a60432c624f75eec52edb Mon Sep 17 00:00:00 2001 From: Lucas Gass Date: Wed, 24 Apr 2024 23:18:15 +0000 Subject: [PATCH] Bug 36694: Add JS observer to detect stuck sticky element Signed-off-by: Owen Leonard --- koha-tmpl/intranet-tmpl/prog/js/staff-global.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js b/koha-tmpl/intranet-tmpl/prog/js/staff-global.js index e357c8b398..b6f165c776 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js +++ b/koha-tmpl/intranet-tmpl/prog/js/staff-global.js @@ -60,6 +60,16 @@ $.fn.selectTabByID = function (tabID) { }; $(document).ready(function () { + //check if sticky element is stuck, if so add floating class + if ( $('#toolbar.sticky').length ) { + const observer = new IntersectionObserver( + ([e]) => e.target.classList.toggle('floating', e.intersectionRatio < 1), + {threshold: [1]} + ); + + observer.observe(document.querySelector('.sticky')); + } + //check for a hash before setting focus let hash = window.location.hash; if (!hash) { -- 2.39.2