Jump to content
Search Community

ScrollTriggers in Wrong Place on Window Resize

ex-jedi test
Moderator Tag

Go to solution Solved by ZachSaucier,

Recommended Posts

When the window is resized the ScrollTriggers are in the wrong place. The CodePen example catches this when you resize down. But on the live site, Business Bookkeeping and Accountancy - Blossom Books, it happens when you both resize down and up. Also I have a side issue where the element markers don't show on resize. I need to refresh for them to reappear.

 

I've kinda fixed it I think by re-running the fadeInRotateParagraphs() function on resize but that's a bit janky (I haven't pushed that to the live site just yet). I'm pretty sure it's me not you. What am I doing wrong?

 

Thanks

See the Pen dypzBqZ?editors=0000 by ex-jedi (@ex-jedi) on CodePen

Link to comment
Share on other sites

  • Solution

Hey ex-jedi. This issue is because ScrollTrigger tries to use the transformed position of elements when determining the ScrollTrigger's trigger position. Since you have rotateX(90deg) in your CSS, the elements are treated like they are 0px tall (because that's what they're rendered at).

 

I recommend not toggling CSS classes and using transitions but instead using GSAP for all of your animations. 

 

Some additional notes:

  • Additionally, this is probably a good use case for using .batch().
  • See this post for how to run a ScrollTrigger when an element is on screen but only reset it if it's off screen.
  • You probably don't even need the matchMedia, I bet you can do it with a couple of regular ScrollTriggers per element.
  • invalidateOnRefresh isn't doing anything for you in this circumstance so you can remove it.
  • Like 2
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...