Bug 36694: Add JS observer to detect stuck sticky element

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Lucas Gass 2024-04-24 23:18:15 +00:00 committed by Katrin Fischer
parent 6f819b68d3
commit 65bdb6592a
No known key found for this signature in database
GPG Key ID: 0EF6E2C03357A834
1 changed files with 10 additions and 0 deletions

View File

@ -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) {