LizF Posted May 10, 2023 Share Posted May 10, 2023 Hi!. On my demo the animations for .block_2 and .block_3 start when the respective containers (.card_2 and .card_3) hit the top. I understand that happens because the lines: trigger: ".card_2", start: "top top", However, I would like the animations for .block_2 and .block_3 start say 200px earlier. In other words, how can I set 2 scrollTriggers, one to pin the containers cards. And another scrollTrigger to start the animation for the blocks earlier? Thanks in advance. See the Pen NWOMbWz by Liz-Franco-the-typescripter (@Liz-Franco-the-typescripter) on CodePen Link to comment Share on other sites More sharing options...
Solution Rodrigo Posted May 10, 2023 Solution Share Posted May 10, 2023 Hi @LizF and welcome to the GreenSock forums! Just add an extra set of ScrollTrigger instances that take care of the container's pinning: ScrollTrigger.create({ trigger: ".card_2", start: "top top", end: "+=200", pin: true, }); gsap .timeline({ scrollTrigger: { trigger: ".card_2", start: "top top+=200", end: "+=200", scrub: true, markers: true, id: "2", toggleActions: "restart pause reverse pause" } }) .from(".block_2", { opacity: 0, duration: 1 }); ScrollTrigger.create({ trigger: ".card_3", start: "top top", end: "+=200", pin: true, }); gsap .timeline({ scrollTrigger: { trigger: ".card_3", start: "top top+=200", end: "+=200", scrub: true, markers: {indent: 150}, id: "3", toggleActions: "restart pause reverse pause" } }) .from(".block_3", { x: 500, duration: 1 }); Here is a fork of your codepen example: See the Pen rNqvzBv by GreenSock (@GreenSock) on CodePen Hopefully this helps. Happy Tweening! 1 Link to comment Share on other sites More sharing options...
LizF Posted May 10, 2023 Author Share Posted May 10, 2023 Ah thank you so much @Rodrigo 👏 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