Jump to content
Search Community

Reset Scroll trigger and animation to innitial values

skyfy test
Moderator Tag

Recommended Posts

Hello,

 

I must be missing something in this code, how can I set default values to have no animation on every load. Currently my header slides down on every page load.

Any suggestions would great appreciated.

 

 useEffect(() => {
    if (typeof window !== `undefined`) {
      gsap.registerPlugin(ScrollTrigger)
      gsap.core.globals('ScrollTrigger', ScrollTrigger)
    }
    const showAnim = gsap
      .from(headerRef.current, {
        yPercent: -100,
        paused: true,
        duration: 1,
      })
      .progress(1)
    ScrollTrigger.create({
      id: 'navbar',
      start: 'top top',
      end: 99999,
      //   scrub: true,
      onUpdate: self => {
        return self.direction === -1 ? showAnim.play() : showAnim.reverse()
      },
    })

    return () => {}
  }, [])

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...