22 lines
571 B
JavaScript
22 lines
571 B
JavaScript
/**
|
|
* Sticky CTA — shows desktop bar when hero scrolls out of view
|
|
*
|
|
* IntersectionObserver on .ds-hero; toggles .visible on .sticky-cta-desktop.
|
|
*
|
|
* @package Dekart
|
|
*/
|
|
|
|
(function () {
|
|
var sticky = document.querySelector('.sticky-cta-desktop');
|
|
var hero = document.querySelector('.ds-hero');
|
|
if (!sticky || !hero) return;
|
|
|
|
var observer = new IntersectionObserver(function (entries) {
|
|
entries.forEach(function (entry) {
|
|
sticky.classList.toggle('visible', !entry.isIntersecting);
|
|
});
|
|
}, { threshold: 0 });
|
|
|
|
observer.observe(hero);
|
|
})();
|