forked from a64f7bb4-7358-4778-9fbe-3b882c34cc1d/v1
17 lines
715 B
JavaScript
17 lines
715 B
JavaScript
(Drupal => {
|
|
Drupal.behaviors.ginSticky = {
|
|
attach: context => {
|
|
once("ginSticky", document.querySelectorAll(".region-sticky-watcher")).forEach((() => {
|
|
const observer = new IntersectionObserver((_ref => {
|
|
let [e] = _ref;
|
|
const regionSticky = context.querySelector(".region-sticky");
|
|
regionSticky.classList.toggle("region-sticky--is-sticky", e.intersectionRatio < 1),
|
|
regionSticky.toggleAttribute("data-offset-top", e.intersectionRatio < 1), Drupal.displace(!0);
|
|
}), {
|
|
threshold: [ 1 ]
|
|
}), element = context.querySelector(".region-sticky-watcher");
|
|
element && observer.observe(element);
|
|
}));
|
|
}
|
|
};
|
|
})(Drupal); |