You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey i'm recreate this animation using next js i'm encounter an issue. my one element is flickering on first render from height and width 100% to the last state of flip states . I'm also create minimal demo on codepen, stackblitz and local but it seems my local and stackblitz demo still encounter the same but on codepen it works.
"use client";importgsap,{Flip,useGSAP}from"@/config/gsap";importReactfrom"react";import"./main.css";exportinterfaceMainProps{containerRef: React.RefObject<HTMLElement|null>;}constMain: React.FC<MainProps>=({ containerRef })=>{return(<mainref={containerRef}suppressHydrationWarning><sectionclassName="content content--initial"><divclassName="one"style={{backgroundImage:
'url("https://ucarecdn.com/ebcff02d-688c-4265-b14f-e868d88b3a88/-/preview/999x669/")',}}/></section><sectionclassName="content content--center content--blend"><divdata-stepclassName="content__img"/><h1className="content__title font-alt"><span>Epen</span><br/><span>Flow</span></h1></section><sectionclassName="content content--column"><divclassName="content__img box"/><divclassName="content__img box"/><divdata-stepclassName="content__img content__img--mid"/><divclassName="content__img box"/><divclassName="content__img box"/></section><sectionclassName="content content--lines"><h2className="content__title content__title--medium font-alt"><span>Lorem</span><divdata-stepclassName="content__img"/><span>Ipsum</span></h2><h2className="content__title content__title--medium font-alt"><span>Crafted with</span><divclassName="content__img box"/><span>Love</span></h2><h2className="content__title content__title--medium font-alt"><span>with</span><divclassName="content__img box"/><span>respect</span></h2></section><sectionclassName="content content--sides"><divdata-stepclassName="content__img"/><divclassName="content__text"><p><strong>Welcome to EF-Studio </strong>
Lorem ipsum dolor sit amet consectetur adipisicing elit.
Vero corrupti dolore omnis possimus natus odit sapiente,
nisi, nulla blanditiis, veritatis ad facilis fugit ipsum
magnam ea! Eaque necessitatibus officia amet.
</p></div></section><sectionclassName="content content--center content--center-tall"><divdata-stepclassName="content__img"/><divclassName="content__text content__text--large"><p>
Lorem ipsum dolor sit amet consectetur adipisicing elit.
Dolorum sit quam quis iste aspernatur, harum inventore
aliquam, maiores commodi praesentium quaerat ea a minima
quasi maxime magni et voluptatem earum.
</p></div></section><sectionclassName="content content--grid"><divclassName="content__img box"/><divdata-stepclassName="content__img"/><divclassName="content__img box"/><divclassName="content__img box"/><divclassName="content__img box"/><divclassName="content__img box"/><divclassName="content__img box"/><divclassName="content__img box"/><divclassName="content__img box"/></section><sectionclassName="outro"><h2className="outro__title font-alt">More you might like</h2><divclassName="card-wrap">{Array.from({length: 5}).map((_,key)=>(<divkey={key}className="card"><divclassName="card__img box"/><spanclassName="card__title font-cap">
Staggered (3D) Grid Animations with
Scroll-Triggered Effects
</span></div>))}</div></section></main>);};functionMainHOC<Textendsobject>(Component: React.ComponentType<T&MainProps>){functionBase(props: T){constcontainerRef=React.useRef<HTMLElement|null>(null);functioncreateFlipOnScrollAnimation(oneElement: Element|null,parentElement: Element|null){conststepElements: HTMLElement[]=gsap.utils.toArray("[data-step]");conststates=stepElements.map((step)=>Flip.getState(step));consttimeline=gsap.timeline({scrollTrigger: {trigger: parentElement,start: "clamp(center center)",endTrigger: stepElements[stepElements.length-1],end: "clamp(center center)",scrub: true,immediateRender: false,// markers: true,},});states.forEach((state,index)=>{timeline.add(Flip.fit(oneElement,state,{duration: 1,ease: index===0 ? "none" : "sine.inOut",// scale: true,// absolute: true,})asGSAPAnimation,index ? "+=0.5" : 0);});}functionanimateSpansOnScroll(){constspans=containerRef.current!.querySelectorAll(".content__title > span");spans.forEach((span,index)=>{constdirection=index%2===0 ? -150 : 150;consttrigger=span.closest(".content--center")
? span.parentElement
: span;gsap.from(span,{x: direction,duration: 1,ease: "sine",scrollTrigger: {trigger: trigger,start: "top bottom",end: "+45%",scrub: true,// markers: true,},});});}functionanimateImageOnScroll(){constimages: HTMLElement[]=gsap.utils.toArray(".content--lines .content__img:not([data-step]), .content--grid .content__img:not([data-step]");images.forEach((image)=>{gsap.fromTo(image,{scale: 0,autoAlpha: 0,filter: "brightness(180%) saturate(0%)",},{scale: 1,autoAlpha: 1,filter: "brightness(100%) saturate(100%)",duration: 1,ease: "sine",scrollTrigger: {trigger: image,start: "top bottom",end: "end+=45%",scrub: true,// markers: true,},});});}functionaddParallaxToText(){constfirstTextElement=containerRef.current?.querySelector(".content__text");if(!firstTextElement)return;gsap.fromTo(firstTextElement,{y: 250,},{y: -250,ease: "sine",scrollTrigger: {trigger: firstTextElement,start: "top bottom",end: "top top",scrub: true,// markers: true,},});}functionanimateFilterOnFirstSwitch(oneElement: Element|null){gsap.fromTo(oneElement,{filter: "brightness(80%)",// width: "100%",// height: "100%",},{filter: "brightness(100%)",ease: "sine",scrollTrigger: {trigger: oneElement,start: "clamp(top bottom)",end: "clamp(bottom top)",scrub: true,// markers: true,},});}functionaddParallaxToColumnImages(){constcolumnImages: HTMLElement[]=gsap.utils.toArray(".content--column .content__img:not([data-step])");consttotalImages=columnImages.length;constmiddleIndex=(totalImages-1)/2;columnImages.forEach((image,index)=>{constintensity=Math.abs(index-middleIndex)*75;gsap.fromTo(image,{y: intensity,},{y: -intensity,ease: "sine",scrollTrigger: {trigger: image,start: "top bottom",end: "bottom top",scrub: true,// markers: true,},});});}useGSAP(()=>{if(!containerRef.current)thrownewError(`Missing Container Reference : Please ensure containerRef is properly injected.`);constoneElement=containerRef.current.querySelector(".one");constparentElement=oneElement!.parentElement;createFlipOnScrollAnimation(oneElement,parentElement);animateSpansOnScroll();animateImageOnScroll();addParallaxToText();animateFilterOnFirstSwitch(oneElement);addParallaxToColumnImages();window.addEventListener("resize",()=>{createFlipOnScrollAnimation(oneElement,parentElement);animateFilterOnFirstSwitch(oneElement);});},{scope: containerRef});return<Component{...props}containerRef={containerRef}/>;}returnBase;}exportdefaultMainHOC(Main);
The text was updated successfully, but these errors were encountered:
Hey i'm recreate this animation using next js i'm encounter an issue. my one element is flickering on first render from height and width 100% to the last state of flip states . I'm also create minimal demo on codepen, stackblitz and local but it seems my local and stackblitz demo still encounter the same but on codepen it works.
The text was updated successfully, but these errors were encountered: