Jump to content


Expand Div Height without scrolling to bottom of div

Go to solution Solved by OSUblake,

Recommended Posts

I'm having some issues with basically imitating jqueries slideToggle ( which didn't work well ) and using scrollTo to try and solve the problem.


The goal is to click on the button ( just click on the first button ) and to have the content expand down below WITHOUT scrolling down.

This works if you are towards the top of the div - before your scrollbar has gotten to the button. But if you scroll past the button and click, it moves you down to the bottom of the page.


( you can see it without my hack if you comment out these lines )


gsap.to(window, {duration:.1, scrollTo:currScroll});
gsap.to(window, {duration: 2, scrollTo: currScroll});


I'm trying to scroll jack and force it from moving down when it expands - any suggestions?



See the Pen bGaBybE by pwhittemore (@pwhittemore) on CodePen

Link to comment
Share on other sites

  • Solution

Hi pdub, 


I'm not sure what you're looking for, but another way would be to just keep setting the scroll position while it's animating.


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


  • Like 3
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.