Instructions

Find easy to follow instructions

This template uses GSAP (GreenSock Animation Platform) to create smooth, high-performance animations across multiple sections of the website. All GSAP scripts are written in pure JavaScript and organized for easy customization, allowing you to adjust animation speed, direction, easing, triggers, and timing without affecting the overall structure.


Each animation includes clear comments to help you understand how it works, making it simple to modify or extend the interactions to match your project's needs while remaining fully compatible with Webflow.
Lenis Script Documentation
This script integrates Lenis, a modern smooth-scrolling library, with GSAP (GreenSock Animation Platform) and ScrollTrigger. It provides an ultra-smooth, high-performance scrolling experience while ensuring all scroll-driven animations stay perfectly synchronized. By routing Lenis's requestAnimationFrame (raf) through GSAP's internal ticker and disabling lag smoothing, the setup prevents jitter and maintains precise scroll position tracking across all devices.
Key Features :
  • Smooth Scrolling: Delivers continuous, fluid scrolling using inertia (lerp: 0.1).
  • GSAP Synchronization: Keeps ScrollTrigger updates aligned with Lenis's custom scroll frame.
  • Lag Smoothing Override: Eliminates animation jumps during sudden frame drops or window re-focusing.
<!-- =========================================================
     LENIS SMOOTH SCROLL
     ---------------------------------------------------------
     Lenis handles smooth scrolling and is synchronized
     with GSAP ScrollTrigger.
     ========================================================= -->

<script src="https://unpkg.com/lenis@1.3.4/dist/lenis.min.js"></script>
<link rel="stylesheet" href="https://unpkg.com/lenis@1.3.4/dist/lenis.css"/>

<script>
  // Initialize Lenis smooth scrolling
  const lenis = new Lenis({
    smooth: true,
    lerp: 0.1,
    wheelMultiplier: 0.75,
    infinite: false,
  });

  // Keep ScrollTrigger synchronized with Lenis
  lenis.on("scroll", ScrollTrigger.update);

  // Run Lenis through the GSAP ticker
  gsap.ticker.add((time) => {
    lenis.raf(time * 1000);
  });

  // Disable GSAP lag smoothing for consistent scroll synchronization
  gsap.ticker.lagSmoothing(0);
</script>
A. How to Edit Lenis Animations
You can adjust the smooth scroll performance and GSAP integration behavior directly in the script using these key parameters:
  1. Lenis Smooth Scroll Settings:
    const lenis = new Lenis({
      smooth: true,          // Enables/disables smooth scrolling (true/false)
      lerp: 0.1,             // Scroll interpolation/smoothness (lower values = smoother/slower catch-up)
      wheelMultiplier: 0.75, // Mouse wheel scroll speed multiplier
      infinite: false,       // Enables or disables infinite looping scroll
    });
  2. GSAP Ticker & Lag Smoothing:
    // Disables GSAP's lag smoothing to ensure GSAP and Lenis tick on the exact same frame
    gsap.ticker.lagSmoothing(0);
B. Removing GSAP Animations
If you want to modify or remove the GSAP synchronization while keeping Lenis smooth scroll, follow these steps:
  1. To disable GSAP synchronization entirely while keeping basic Lenis smooth scrolling, remove or comment out the GSAP integration lines:
    // Remove or comment out these lines:
    
    // lenis.on("scroll", ScrollTrigger.update);
    // gsap.ticker.add((time) => { lenis.raf(time * 1000); });
    // gsap.ticker.lagSmoothing(0);
  2. Replace the ticker update with standard requestAnimationFrame logic to keep Lenis running independently:
    function raf(time) {
      lenis.raf(time);
      requestAnimationFrame(raf);
    }
    requestAnimationFrame(raf);
Featured Portfolio Hover Animation
The script also manages animation transitions, prevents overlapping animations, and automatically restores the default portfolio appearance when users move their cursor outside the portfolio area.
Key Features :
  • Interactive Hover Animation: Triggers animations when users hover over portfolio cards.
  • Dynamic Title Switching: Displays the corresponding project title based on the hovered card variant.
  • Word-by-Word Reveal: Uses SplitType to animate each title word individually.
  • Overlay Effect: Removes the overlay from the active card while dimming the other cards.
  • Smooth Transitions: Uses GSAP timelines to synchronize multiple animation elements.
  • Automatic Reset: Restores the default portfolio state when the cursor leaves the entire portfolio area.
  • Animation Conflict Prevention: Kills previous timelines and tweens before starting a new animation.
<script>
  window.Webflow = window.Webflow || [];
  window.Webflow.push(function () {
    if (!window.gsap) return;

    const gsap = window.gsap;
    const root = document.querySelector('.wrapper-circle-featured');
    if (!root || root.dataset.portfolioHoverReady === 'true') return;
    root.dataset.portfolioHoverReady = 'true';

    const cards = Array.from(root.querySelectorAll('.block-image-feature'));
    const heading = document.querySelector('.wrapper-title-featured');
    const titles = Array.from(document.querySelectorAll('.title-project'));
    if (!cards.length) return;

    // Card variant -> title variant, matching the original portfolio hover setup.
    const titleVariantByCard = {
      v1: 'v2',
      v2: 'v4',
      v3: 'v1',
      v4: 'v1',
      v5: 'v3',
      v6: 'v3',
    };

    const splitInstances = [];
    titles.forEach((el) => {
      if (window.SplitType) splitInstances.push(new SplitType(el, { types: 'words' }));
    });

    const wordsFor = (elements) => elements.flatMap((el) => Array.from(el.querySelectorAll('.word')));
    const allWords = wordsFor(titles);

    gsap.set(titles, { autoAlpha: 0 });
    gsap.set(allWords, { yPercent: 30, autoAlpha: 0 });

    const overlayFor = (card) => card.querySelector('.overlay-featured');
    const allOverlays = cards.map(overlayFor).filter(Boolean);

    let activeTimeline = null;
    let activeCard = null;

    function stopCurrentAnimation() {
      if (activeTimeline) activeTimeline.kill();
      activeTimeline = null;
      gsap.killTweensOf([...allOverlays, heading, ...titles, ...allWords].filter(Boolean));
    }

    function activateCard(card) {
      if (activeCard === card) return;
      stopCurrentAnimation();
      activeCard = card;

      const activeOverlay = overlayFor(card);
      const otherOverlays = allOverlays.filter((overlay) => overlay !== activeOverlay);

      const cardVariant = Array.from(card.classList).find((name) => /^v[1-6]$/.test(name));
      const titleVariant = titleVariantByCard[cardVariant];
      const matchingTitles = titleVariant ? titles.filter((el) => el.classList.contains(titleVariant)) : [];
      const otherTitles = titles.filter((el) => !matchingTitles.includes(el));
      const matchingWords = wordsFor(matchingTitles);

      activeTimeline = gsap.timeline({ defaults: { overwrite: true } });

      // Explicitly clear the hovered card's overlay; dim only every other card.
      if (activeOverlay) {
        activeTimeline.to(
          activeOverlay,
          {
            autoAlpha: 0,
            duration: 0.25,
            ease: 'power2.out',
          },
          0,
        );
      }
      if (otherOverlays.length) {
        activeTimeline.to(
          otherOverlays,
          {
            autoAlpha: 0.8,
            duration: 0.5,
            ease: 'power2.out',
          },
          0,
        );
      }

      if (heading) {
        activeTimeline.to(
          heading,
          {
            autoAlpha: 0,
            duration: 0.35,
            ease: 'power2.out',
          },
          0,
        );
      }

      if (otherTitles.length) {
        activeTimeline.set(otherTitles, { autoAlpha: 0 }, 0);
      }
      if (matchingTitles.length) {
        activeTimeline.set(matchingTitles, { autoAlpha: 1 }, 0.12);
      }
      if (matchingWords.length) {
        activeTimeline.fromTo(
          matchingWords,
          { yPercent: 30, autoAlpha: 0 },
          {
            yPercent: 0,
            autoAlpha: 1,
            duration: 0.5,
            stagger: 0.035,
            ease: 'power3.out',
          },
          0.17,
        );
      }
    }

    function resetPortfolio() {
      stopCurrentAnimation();
      activeCard = null;

      gsap.to(allOverlays, {
        autoAlpha: 0,
        duration: 0.35,
        ease: 'power2.out',
        overwrite: true,
      });
      if (heading) {
        gsap.to(heading, {
          autoAlpha: 1,
          duration: 0.35,
          ease: 'power2.out',
          overwrite: true,
        });
      }
      gsap.to(titles, { autoAlpha: 0, duration: 0.2, overwrite: true });
      gsap.to(allWords, {
        yPercent: 30,
        autoAlpha: 0,
        duration: 0.2,
        stagger: 0.01,
        ease: 'power2.in',
        overwrite: true,
      });
    }

    cards.forEach((card) => {
      card.addEventListener('mouseenter', () => activateCard(card));
    });

    // Reset only after leaving the whole portfolio card area.
    root.addEventListener('mouseleave', resetPortfolio);

    window.addEventListener(
      'pagehide',
      () => {
        if (activeTimeline) activeTimeline.kill();
        splitInstances.forEach((split) => split.revert());
      },
      { once: true },
    );
  });
</script>
A. How to Edit Portfolio Hover Animations
You can customize the animation behavior directly in the script using the following settings.
  1. Card-to-Title Variant Mapping
    //This object determines which project title appears when a specific portfolio card is hovered.
    
    const titleVariantByCard = {
      v1: 'v2',
      v2: 'v4',
      v3: 'v1',
      v4: 'v1',
      v5: 'v3',
      v6: 'v3',
    };
  2. Animation Speed and Timing
    duration: 0.25, // Active card overlay fade-out
    duration: 0.5,  // Other cards overlay fade-in
    
    duration: 0.35, // Main heading fade-out
    
    duration: 0.5,  // Word reveal duration
    stagger: 0.035, // Delay between each word
    
    duration: 0.35, // Overlay and heading reset
    duration: 0.2,  // Project title fade-out
B. How to Add or Remove Portfolio Cards
The script automatically detects portfolio cards inside the main wrapper.
const root = document.querySelector('.wrapper-circle-featured');

const cards = Array.from(
  root.querySelectorAll('.block-image-feature')
);
To add a new portfolio card:

1. Add a new element using the .block-image-feature class.
2. Assign a variant class such as v1, v2, or v3.
3. Add an .overlay-featured element inside the card.
4. Make sure the corresponding project title has the matching title variant class.
5. Update the titleVariantByCard object if necessary.
‍
The script currently supports the v1 to v6 card variants.

If you introduce a new variant, remember to add its mapping to the object.