Jump to content
Search Community

Setting same animation for multiple elements to get triggered individually (GSAP + ScrollTrigger)

aki-sol test
Moderator Tag

Go to solution Solved by OSUblake,

Recommended Posts



I'm really excited to get the opportunity to work with gsap! I'm currently having an issue with reusing the same gsap function for multiple elements.

My goal is, that each box-container gets triggered individually when they come into the viewport. Currently, the animation function is only applied to the first box-container, which is also the only one that has gotten a scrollTrigger marker applied to it. What I want however, is that each bock-container gets their own markers and is triggered individually. To me, my demo really makes sense but it's obviously not achieving what I need. I would really appreciate if someone could explain to me where I went wrong ^^




Edit: I've changed the animations from when I first posted, but I added some comments to the codepen for later viewers that might experience the same problem to see the progression. 

See the Pen ExmeapK by aki-sol (@aki-sol) on CodePen

Link to comment
Share on other sites

Thanks a lot Cassie! It's a great article and it helped me find some mistakes! In the function that I initially set up I failed to use the identifier from the forEach() as the trigger.  As advised by the article I also changed the gsap function from "from" to "fromTo" which helped with the proper timing of the animation starting for each module, even though I must admit I haven't really understood why this is the right solution yet. 


However, the animation is behaving strangely. I don't understand why the boxes jump back up and down at random times which in some cases also messes up the animation timing for the second container. I thought that setting an explicit end point would fix it but that does not see to be the problem here. 

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