Jump to content
Search Community

Reset TimeLineMax props inside each loop on scroll?

pikemilsner test
Moderator Tag

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

Howdy folks,

 

I've spent most of the afternoon on this, just about have it hacked together.

My JS chops are weak at best, thanks for any guidance in advance :)

 

I'm missing a method to reset my timeline element (.modal) positioning as to recalculate the active modal distance from the top of the viewport. Works nice for the first modal, before scrolling, but the second modal as you'll see uses the initial top: $(document).scrollTop() even though the doc has been scrolled. 

 

Goal: Make the modal 100% viewport height and width, fixed top, while animating from the clicked button.

 

 

Cheers ~ 

MP

 

See the Pen pKaymz by pikemilsner (@pikemilsner) on CodePen

 

 

 

 

See the Pen pKaymz by pikemilsner (@pikemilsner) on CodePen

Link to comment
Share on other sites

I think the solution here is to calculate the coordinates when you click on the button because where the button is in the viewport is going to determine the precise locations the modal needs to grow from and to.

 

@OSUblake has this great demo where modals grow from the boxes you click on. You can resize the window to change the flow/position of the boxes and the "modal" always animates to and from the right places. He does this by cloning the element and calculating the coordinates on each click.

See the Pen WwgQEV?editors=0011 by osublake (@osublake) on CodePen

 

 

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