Skip to content

Instantly share code, notes, and snippets.

@Mr2P
Created December 21, 2022 00:53
Show Gist options
  • Select an option

  • Save Mr2P/9c63a9031c9dde87324b30d64f6c7b17 to your computer and use it in GitHub Desktop.

Select an option

Save Mr2P/9c63a9031c9dde87324b30d64f6c7b17 to your computer and use it in GitHub Desktop.
The script for the animated title block
// 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