"use client"; import gsap from "gsap"; import { ScrollTrigger } from "gsap/ScrollTrigger"; import { useEffect } from "react"; gsap.registerPlugin(ScrollTrigger); export default function Banner() { useEffect(() => { // Select all elements with the class "text-container" inside ".banner-stripe" const textContainers = document.querySelectorAll( ".banner-stripe .text-container" ); textContainers.forEach((container) => { const settings = { scrollTrigger: { trigger: container, start: "top bottom", // Animation starts when the top of the element hits the bottom of the viewport end: "bottom top", // Animation ends when the bottom of the element hits the top of the viewport scrub: 1, // Smooth scrubbing effect markers: false, // Disable debug markers }, ease: "none", // No easing }; // Check if the element has the class "effect-left" or "effect-right" if (container.classList.contains("effect-left")) { settings.x = "-7%"; // Move left by 7% } if (container.classList.contains("effect-right")) { settings.x = "7%"; // Move right by 7% } // Apply the GSAP animation gsap.to(container, settings); }); // Cleanup ScrollTrigger instances on component unmount return () => { ScrollTrigger.getAll().forEach((trigger) => trigger.kill()); }; }, []); // Empty dependency array ensures this runs only once after mount return (
Email Business Marketing Consulting Money Email Business Marketing Consulting Money
); }