Jump to content
Search Community

Gatsby matchMedia makes items "disappear"

IanStews test
Moderator Tag

Recommended Posts

I've been having this weird bug/ issue in combination with ScrollTrigger.matchMedia and resizing the browser in Gatsby. When resizing the items seem to get stuck in the pre-animation state (making them disappear). I would expect to see the blocks do their animations after a resize but instead I'm just seeing the start state and nothing else.

**Note: This only happens when resizing the browser without any reloads. If you resize and reload it will animate according to the query.

I've made a simple example for you guys to have a look at in CodeSandbox: https://codesandbox.io/s/gatsby-gsap-matchmedia-issue-l04x8

Link to comment
Share on other sites

Hey @IanStews,

I wish I had a proper explanation for you - but I guessed it might be something to do with react's render loop/refreshing and the fact that from tweens are immediately rendered. 🤷🏼‍♀️

I swopped the initial set to move the elements down and make them hidden and then animated using to() and it worked.

Can't explain. Dumb luck. Maybe @OSUblake will be able to give you a more educated analysis.

https://codesandbox.io/s/gatsby-gsap-matchmedia-issue-forked-k8d87?file=/src/components/Blocks.jsx

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