Dave Dublin Posted September 8, 2022 Share Posted September 8, 2022 Hi Is it possible to click to a point in the timeline animation? I tried to utilise the following code but I think I am missing something. Should I be using Labels? The idea is that you can click on the number and it will scroll to the card gsap.utils.toArray(".nav a").forEach((a, i) => { a.addEventListener("click", e => { e.preventDefault(); gsap.to(window, {scrollTo: i * innerWidth}) }); }); See the Pen dyeYdRK by davedublin (@davedublin) on CodePen Link to comment Share on other sites More sharing options...
GreenSock Posted September 8, 2022 Share Posted September 8, 2022 You really don't need jQuery. It's a waste in this case and you're eating up a lot of resources with that scroll event handler. Here's a version that shows a different approach: See the Pen QWryzba?editors=0010 by GreenSock (@GreenSock) on CodePen FYI, there are some helper functions in the docs related to getting scroll positions although they don't necessarily fit this case (I just wanted to let you know they are there): https://greensock.com/docs/v3/HelperFunctions#getScrollPosition I hope that helps! Link to comment Share on other sites More sharing options...
Dave Dublin Posted September 8, 2022 Author Share Posted September 8, 2022 Wow brilliant, thanks so much. That's working much better now. Thanks Dave 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