kmytor Posted October 7, 2022 Share Posted October 7, 2022 Hi, I am using scrollTo() it doesn't animate, it makes small jumps, sometimes it works if it is animated and it jumps when it is immobile, I don't know what is happening. See the Pen OJZBMjj by kmytor (@kmytor) on CodePen Link to comment Share on other sites More sharing options...
Solution Rodrigo Posted October 8, 2022 Solution Share Posted October 8, 2022 Hi, The issue is that all your links have an href attribute that points to that specific tag href="#post__0", so that basically takes the window to that section immediately which prevents the ScrollTo Plugin from doing it's job. Simply prevent the default functionality on the click event and watch your app smoothly scroll to the section you want: btn.addEventListener("click", (e) => { e.preventDefault(); // <- THIS gsap.to(window, { duration: 1, scrollTo: { y: "#post__" + index, offsetY: 70, ease: "power2" } }); }); Happy Tweening! 2 1 Link to comment Share on other sites More sharing options...
kmytor Posted October 11, 2022 Author Share Posted October 11, 2022 thank you very much 1 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