Created
December 21, 2022 00:53
-
-
Save Mr2P/9c63a9031c9dde87324b30d64f6c7b17 to your computer and use it in GitHub Desktop.
The script for the animated title block
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
| // https://cdn.jsdelivr.net/npm/[email protected]/dist/splitting.min.js | |
| (() => { | |
| const animatedClass = 'is-animated'; | |
| const observer = new IntersectionObserver((entries) => { | |
| entries.forEach((entry) => { | |
| animateElement(entry.target, entry.isIntersecting); | |
| }); | |
| }, {rootMargin: '0px'}); | |
| const animateElement = (element, isToggle) => { | |
| element.classList.toggle(animatedClass, isToggle); | |
| } | |
| const headingElements = document.querySelectorAll('BLOCKSELECTOR .is-animated-heading'); | |
| if (headingElements.length) { | |
| headingElements.forEach((animatedElement) => { | |
| Splitting({ | |
| target: animatedElement, | |
| }); | |
| observer.observe(animatedElement); | |
| }); | |
| } | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment