|
1 | | -const swiper = new Swiper('.about-team_slider', { |
2 | | - // Optional parameters |
3 | | - slidesPerView: 'auto', |
4 | | - spaceBetween: 20, |
5 | | - // Navigation arrows |
6 | | - navigation: { |
7 | | - nextEl: '.swiper-arrow.next', |
8 | | - prevEl: '.swiper-arrow.prev', |
9 | | - }, |
10 | | -}); |
11 | | - |
12 | | -const swiperModal = new Swiper('.about-team_modal-slider .max-width-full', { |
13 | | - // Optional parameters |
14 | | - slidesPerView: 1, |
15 | | - noSwiping: false, |
16 | | - navigation: { |
17 | | - prevEl: '.about-team-modal-arrow.prev', |
18 | | - nextEl: '.about-team-modal-arrow.next', |
19 | | - }, |
20 | | - breakpoints: { |
21 | | - 0: { |
22 | | - direction: 'horizontal', |
23 | | - spaceBetween: 8, |
24 | | - autoHeight: true, |
25 | | - }, |
26 | | - 992: { |
27 | | - direction: 'vertical', |
28 | | - spaceBetween: 20, |
29 | | - autoHeight: false, |
30 | | - }, |
31 | | - }, |
32 | | -}); |
| 1 | +gsap.registerPlugin(ScrollTrigger, SplitText); |
33 | 2 |
|
34 | | -$('.about-team_card').on('click', function () { |
35 | | - revealModal($(this).closest('.w-dyn-item').index()); |
36 | | -}); |
| 3 | +function initHighlightText() { |
| 4 | + let splitHeadingTargets = document.querySelectorAll('[data-highlight-text]'); |
| 5 | + splitHeadingTargets.forEach((heading) => { |
| 6 | + const scrollStart = heading.getAttribute('data-highlight-scroll-start') || 'top 70%'; |
| 7 | + const scrollEnd = heading.getAttribute('data-highlight-scroll-end') || 'center 40%'; |
| 8 | + const fadedValue = heading.getAttribute('data-highlight-fade') || 0.2; // Opacity of letter |
| 9 | + const staggerValue = heading.getAttribute('data-highlight-stagger') || 0.1; // Smoother reveal |
37 | 10 |
|
38 | | -$('.blog-detail_hero-list-item') |
39 | | - .not('[fs-cmsstatic-element]') |
40 | | - .on('click', function () { |
41 | | - revealModal($(this).closest('.w-dyn-item').index()); |
| 11 | + new SplitText(heading, { |
| 12 | + type: 'words, chars', |
| 13 | + autoSplit: true, |
| 14 | + onSplit(self) { |
| 15 | + let ctx = gsap.context(() => { |
| 16 | + let tl = gsap.timeline({ |
| 17 | + scrollTrigger: { |
| 18 | + scrub: true, |
| 19 | + trigger: heading, |
| 20 | + start: scrollStart, |
| 21 | + end: scrollEnd, |
| 22 | + }, |
| 23 | + }); |
| 24 | + tl.from(self.chars, { |
| 25 | + autoAlpha: fadedValue, |
| 26 | + stagger: staggerValue, |
| 27 | + ease: 'linear', |
| 28 | + }); |
| 29 | + }); |
| 30 | + return ctx; // return our animations so GSAP can clean them up when onSplit fires |
| 31 | + }, |
| 32 | + }); |
42 | 33 | }); |
43 | | - |
44 | | -$('[data-modal="hide"]').on('click', hideModal); |
45 | | - |
46 | | -function revealModal(index) { |
47 | | - swiperModal.slideTo(index); |
48 | | - $('.about-team_modal').fadeIn(); |
49 | | - $('html, body').addClass('overflow-hidden'); |
50 | 34 | } |
51 | 35 |
|
52 | | -function hideModal() { |
53 | | - $('.about-team_modal').fadeOut(); |
54 | | - $('html, body').removeClass('overflow-hidden'); |
55 | | -} |
| 36 | +// Initialize Highlight Text on Scroll |
| 37 | +document.addEventListener('DOMContentLoaded', () => { |
| 38 | + initHighlightText(); |
| 39 | +}); |
0 commit comments