beenjamin Posted February 26 Posted February 26 I have a timeline and a tween+scrollTrigger. I instantiate the timeline then instantiate the tween+scrollTrigger. After that, I add the tween to the timeline via "TIMELINE.add(TWEEN)" The element is just "jumping" instead of animating the element. But when I remove the line where i "add" the tween to the timeline, it animates it as it should... why is that so?? Here is a demo via codepen See the Pen WbNobYd by Ben-jamin-the-reactor (@Ben-jamin-the-reactor) on CodePen.
Solution Rodrigo Posted February 26 Solution Posted February 26 Hi, You're making one of the most common ScrollTrigger mistakes, adding a ScrollTrigger configuration to a Tween that is a child of a Timeline: https://gsap.com/resources/st-mistakes#nesting-scrolltriggers-inside-multiple-timeline-tweens This seems to work the way you intend: var tl = gsap.timeline({ scrollTrigger: { trigger: '.green', start: 'clamp(top 50%)', end: 'top 20%', markers: true, }, }); var tween = gsap.from('.green', { x: 350, }) tl.add(tween); Also you might want to check the start point of your ScrollTrigger instance and see the clamp() feature: https://gsap.com/docs/v3/Plugins/ScrollTrigger/?page=1#start Hopefully this helps Happy Tweening! 1
beenjamin Posted February 26 Author Posted February 26 ah god damn 🙈 i have read that AND have forgottten it 😶. Note to myself 🫵 so its basically: -Timeline(ScrollTrigger) -Tween OR -Tween(ScrollTrigger) AND NOT -Timeline -Tween(ScrollTrigger) Thanks a lot for clarification!
GreenSock Posted February 26 Posted February 26 17 minutes ago, beenjamin said: so its basically: -Timeline(ScrollTrigger) -Tween OR -Tween(ScrollTrigger) AND NOT -Timeline -Tween(ScrollTrigger) Exactamundo. ✅ Have fun!
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