tomw_uk Posted August 9, 2021 Share Posted August 9, 2021 Hi there, I'm trying to trigger some additional javascript within the `onComplete` callback on stagger within ScrollTrigger.batch(). I found this thread but `this` is undefined when I put it inside a batch call like so: ScrollTrigger.batch('.show', { onEnter: (elements, triggers) => { gsap.to(elements, { y: 0, opacity: 1, duration: 1, stagger: { each: 0.3, onComplete: () => { console.log(this) } } }) }, }) Is there any way I can I can access the element when its animation has finished? Thanks in advance, Tom. Link to comment Share on other sites More sharing options...
Solution OSUblake Posted August 9, 2021 Solution Share Posted August 9, 2021 Arrow functions aren't scoped, so you can't use this like that. You would need to use a regular function. onComplete() { console.log(this) } 2 1 Link to comment Share on other sites More sharing options...
tomw_uk Posted August 9, 2021 Author Share Posted August 9, 2021 Of course! Thank you. Couldn’t see the wood through the trees there. 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