Last active
November 25, 2022 09:52
-
-
Save nerkat/ce6a81d1365001df314244e5545e02c2 to your computer and use it in GitHub Desktop.
Shopify - add scroll animation to all sections
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let observer = new IntersectionObserver((entries, observer) => { | |
entries.forEach(entry => { | |
if (entry.isIntersecting) { | |
entry.target.animate([ | |
{ | |
transform: 'translateY(30px)', | |
opacity: 0, | |
filter: 'blur(10px)' | |
}, | |
{ transform: 'translateY(0px)', | |
opacity: 1, | |
filter: 'blur(0px)' | |
} | |
], { | |
duration: 1000, | |
iterations: 1, | |
easing: 'ease-in-out', | |
direction: 'normal' | |
}); | |
} | |
}); | |
}); | |
document.querySelectorAll('.shopify-section').forEach((section) => { | |
observer.observe(section); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment