Jump to content
Search Community

ScrollTrigger conflict with previous animation

Richard1604 test
Moderator Tag

Recommended Posts

Hello,

I have been putting together an animation which has a stagger followed by a scrollTrigger script.

If I comment out the stagger (line #15: tl.to(".rowx", {stagger: 0.25, height: "1"  });)

then the scrollTrigger script works as expected however if I include the stagger then scrollTrigger seems to have the markers in the wrong place.

I have tried various combinations like refresh() to no avail.

Please could you advise.

Thanks.

See the Pen KKzXogK by rb1604 (@rb1604) on CodePen

Link to comment
Share on other sites

Hey Richard. You are changing the amount of scroll on the page and not telling ScrollTrigger to update, so yes, of course it will be off :)

 

To fix it, just tell ScrollTrigger to update afterwards: 

var tl = gsap.timeline({onComplete: () => ScrollTrigger.refresh()});

Site notes: 

  • We recommend using xPercent and yPercent for setting translations in percentages.
  • It doesn't really make sense to have ScrollTriggers on tweens inside timelines. We recommend looping through each element and creating a ScrollTrigger for each. It'd also keep your code more DRY.
  • I highly recommend using more standard code formatting - your code is very hard for me to read 😆
  • Like 1
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...