Jump to content
Search Community

ScrollTrigger Weirdness - Gatsby.Js

Steve Giorgi test
Moderator Tag

Recommended Posts

Firstly, I'm trying to create demos for anything I post -- I know that's key to giving you guys something to go on.  Would it work to create a demo in Codeasndbox in this case?   I was kindly asked to avoid it but I'm not sure I can replicate this behavior on Codepen.  If so, I'll attempt to replicate there.

 

This occurs on screen resize and hot refresh in Gatsby.js:

 

image.thumb.png.48d9404285e1c34d281914520de71688.png

  

The ScrollTrigger (is this simply a result of invalidateRefresh?)  This is wrapped in a useEffect with an empty dependency:

 

tlEnergyTransition1.current = gsap
      .timeline({
        paused: true,
        scrollTrigger: {
          trigger: scrollContainer2Ref.current,
          start: 'center center',
          toggleActions: 'play none none reverse',
          invalidateOnRefresh: true,
        },
      })
Link to comment
Share on other sites

On 8/6/2021 at 9:38 PM, Steve Giorgi said:

The ScrollTrigger (is this simply a result of invalidateRefresh?)  This is wrapped in a useEffect with an empty dependency:

 

What's the reason for using an empty dependency? At the very least, you should at least return a cleanup function. 

return () => {
  tlEnergyTransition1.current.scrollTrigger.kill();
  tlEnergyTransition1.current.kill();
}

 

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...