JackW Posted Thursday at 08:28 PM Share Posted Thursday at 08:28 PM Hi all, Having a persistent issue across a number of projects with ScrollTrigger layouts breaking after resizing the screen height. I've attached a codepen that demonstrates the issue we're having: To replicate: Scroll down past the gray section until you can see the text fade in and the second section is locked. Change the height by expanding the preview box vertically while looking at the locked text section. You can leave it at the new height or resize it back; it doesn't matter. Scroll back up to the start of the locked section. You should see the text no longer fades in and starts later in its animation. Refresh the window and the animation should be back to its normal state. I'm not sure if we're doing something wrong here, or there's a bug. Invalidate On Refresh doesn't seem to help at all. I'm wondering if it's related to the section being 100vh. I've also attached a zip with a demo project, which might be easier to debug. Thanks in advance! -Jack demo.zip See the Pen MWdrWBN by climber (@climber) on CodePen Link to comment Share on other sites More sharing options...
Solution Cassie Posted Friday at 12:26 PM Solution Share Posted Friday at 12:26 PM Hiya! You just needed to specify a pinnedContainer because you were had a trigger inside an element that you'd pinned. A few notes - If you're just pinning an element you can use ScrollTrigger.create() - no need to make a timeline. Timelines are only useful if you're sequencing tweens. - You're using a lot of fromTo tweens, fromTo tweens are only necessary when you need to set an explicit start and end position. If you have an element that's already at opacity:1, no need to do a "fromTo" from opacity 1 to opacity 0, you can just do a "to" opacity:0 - it will take the start position from the value that already exists on the elements https://gsap.com/resources/mistakes/#using-fromto-when-from-or-to-would-work - You also had a stagger here that was set to 0.0, so not doing anything, I removed that. See the Pen eYaaBXg?editors=0010 by GreenSock (@GreenSock) on CodePen Hope this helps! Link to comment Share on other sites More sharing options...
JackW Posted Friday at 01:49 PM Author Share Posted Friday at 01:49 PM Looks like that fixed the issue- thanks! Going to look over the code and apply that back to our current project. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now