Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // STICKY SHOW BOTTOM
- const el = document.querySelector(".product-sub-footer")
- function addShadow(x) {
- if (x.matches) { // If media query matches
- const observer = new IntersectionObserver(
- ([e]) => e.target.classList.toggle("sticky-shadow", e.intersectionRatio < 1),
- { threshold: [1] }
- );
- observer.observe(el);
- }
- else {
- el.classList.remove("sticky-shadow");
- }
- }
- var x = window.matchMedia("(min-width: 768px)")
- addShadow(x) // Call listener function at run time
- x.addListener(addShadow) // Attach listener function on state changes
- const els = document.querySelector(".product-sub-detail")
- const observers = new IntersectionObserver(
- ([e]) => e.target.classList.toggle("sticky-shadow", e.intersectionRatio < 1),
- { threshold: [1] }
- );
- observers.observe(els);
- // STICKY SHOW TOP
- const nav = document.querySelector(".sticky-nav")
- const observer = new IntersectionObserver(
- entries => {
- entries.forEach(entry => {
- if(!entry.isIntersecting) {
- entry.target.classList.add("sticky-shadow")
- } else{
- entry.target.classList.remove("sticky-shadow")
- }
- })
- }, {threshold: 0.9,}
- )
- observer.observe(nav);
Add Comment
Please, Sign In to add comment