Jump to content
Search Community

How can i scroll to a section that is inside a overflow container?

Balram test
Moderator Tag

Recommended Posts

Hi,

 

I am trying to go to a section on click. I tried to use scrollIntoView() it did go to the section but didn't trigger the gsap animation while going back so i found a plugin from gsap ScrollToPlugin that worked with other element but didn't work with section within a container that is set to overflow.

 

I have added a codepen it's a bit messy but i hope you get what i want to do.

See the Pen OJaxpKj by veuxon (@veuxon) on CodePen

Link to comment
Share on other sites

Hi,

 

I've read your post a few times and went through your code and I'm not 100% sure that I follow exactly what you're trying to do.

 

From the context I infer that you might be behind something like this:

See the Pen poKEEKB by GreenSock (@GreenSock) on CodePen

 

Also this example can help as well:

See the Pen VwBmpMQ by GreenSock (@GreenSock) on CodePen

 

Hopefully this helps getting you started. If you keep having issues, please be super specific about what you're trying to do (if possible include a link that shows the behaviour you're trying to achieve).

Happy Tweening!

Link to comment
Share on other sites

11 hours ago, Rodrigo said:

Hi,

 

I've read your post a few times and went through your code and I'm not 100% sure that I follow exactly what you're trying to do.

 

From the context I infer that you might be behind something like this:

 

 

 

Also this example can help as well:

 

 

 

Hopefully this helps getting you started. If you keep having issues, please be super specific about what you're trying to do (if possible include a link that shows the behaviour you're trying to achieve).

Happy Tweening!

Thanks for replying, but I don't think this will do. What I am trying to achieve is scrolling into an element that is inside a container that is set to overflow scroll. I made some modifications to the code to make it even simpler to understand.

 

 

Now, when I click on the button that is supposed to make that element come to view, it just scrolls to the top or bottom, but when the element is in view, it does scroll to the top. I want to achieve this behaviour even when the element is not in view.

 

Link to comment
Share on other sites

Nevermind, I found a solution. What worked for me was to make the element inside the overflow container scroll to top of the container and then when the element is visible in body then i used the scroll to plugin and it worked like a charm.

  • Like 1
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...