gn90 Posted April 11, 2022 Share Posted April 11, 2022 Hi there, so i am quite new to the GSAP community but so far i created a few, cool small things. Since yesterday i struggle with the scrollto functionality. I discovered in other posts of this forum how to do it (also with a fixed navigation on the left side). In every section i have some "prev" and "next" buttons. As u can see it always scrolls to the end of the page if u click them. I am not really that good in plain javascript so its quite hard for me to understand the target calculation i copied from another post. I just thought it would be enough to set the element as target. But i guess since we are in a horizontal scrolltrigger it handles it different. Thanks in advance, Gui See the Pen KKZBprM by gn90at (@gn90at) on CodePen Link to comment Share on other sites More sharing options...
Cassie Posted April 11, 2022 Share Posted April 11, 2022 Hey there! I think this solution may be helpful. 3 Link to comment Share on other sites More sharing options...
gn90 Posted April 11, 2022 Author Share Posted April 11, 2022 Thank you for your reply. It works waay better now due to this function. But still not perfect. Could it be because of my fixed navigation on the left thats overlapping? Is there a way to include this in the calculations? Thank you, Gui Link to comment Share on other sites More sharing options...
Solution GreenSock Posted April 11, 2022 Solution Share Posted April 11, 2022 Yep, since you've got a 170px sidebar obscuring things, you just need to tell the getPosition() to use "left 170px" instead of "left left". See the Pen GRyBmwe?editors=1010 by GreenSock (@GreenSock) on CodePen Is that what you wanted? 2 Link to comment Share on other sites More sharing options...
gn90 Posted April 11, 2022 Author Share Posted April 11, 2022 ohh wow thank you! you are awesome. thanks for the help! 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