carhop__carhop-theme__DEV/resources/js/animation/animations.js
2026-05-13 18:01:11 +02:00

39 lines
914 B
JavaScript

const tl = gsap.timeline({
defaults: {
duration: 1,
y: -14,
opacity: 0,
ease: 'power4.out',
},
});
function pageHeaderAnimationInit() {
const contentElements = document.querySelectorAll(
'.page-header .page-header__content *',
);
const cover = document.querySelector('.page-header__image');
if (contentElements.length > 0) {
tl.from(contentElements, {}, '<');
}
if (cover) {
tl.from(cover, { delay: 0.2 }, '<');
}
}
function chapterSectionAnimationInit() {
const contentElements = document.querySelectorAll(
'.wp-block-carhop-blocks-chapter-section .chapter-section__content *',
);
const cover = document.querySelector('.chapter-section__cover');
if (contentElements.length > 0) {
tl.from(contentElements, {}, '<');
}
if (cover) {
tl.from(cover, { delay: 0.2 }, '<');
}
}
export { pageHeaderAnimationInit, chapterSectionAnimationInit };