Jump to content
Search Community

Expand section append child on click

Tommie.lehmann test
Moderator Tag

Go to solution Solved by Rodrigo,

Recommended Posts

Pls have a look at my pen:

 

I have been trying to work with an effect like this https://spaincollection.com/destinations/north-of-spain/nature but on horizontal sections.. I have the expand and tried all sort of resize event listeners but somehow I can't make it maintain scroll position and push out both up and down to expand.. pls.. I am not a pro is this but really trying to learn.. ;) any suggestions?  I would of course like the expanded section to end up centered on screen.. 

 

By the way I still didn't figure out why the smooth transition isn't working before second click?

See the Pen oNabRdv by tommie-lehmann (@tommie-lehmann) on CodePen

Link to comment
Share on other sites

  • Solution

Hi,

 

What you can do is create an array with the original top position of each section and use the ScrollTo Plugin in order to scroll to that particular position using GSAP:

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

 

Finally, when a section is expanded I strongly recommend you to disable the scrolling by setting overflow hidden in the document and use the Observer Plugin to watch for different events as wheel, pointer, touch, etc., in order to move your content up and down:

https://greensock.com/docs/v3/Plugins/Observer

 

Hopefully this helps.

Happy Tweening!

  • Like 1
  • Haha 1
Link to comment
Share on other sites

Hi,

 

This is the starting point in the Observer docs:

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

 

Also this collection offers a series of great examples that can provide inspiration:

https://codepen.io/collection/KpNYOd

 

This thread also has a couple of examples that increase the progress of a GSAP instance based on the Observer Plugin:

 

Of course the most important thing is that you provide a minimal demo of your own that shows exactly what you have and where the issue actually is.

 

Hopefully this helps.

Happy Tweening!

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...