Jump to content
Search Community

Adjust Widths on Resize

pietM test
Moderator Tag

Go to solution Solved by Cassie,

Recommended Posts

HI everyone,  

 

Likely a common question, but I can't find a clear solution after searching the forums.

I have elements in a div that distribute by flex after a "mouseenter" event. The widths are set to "auto," so they shift once the browser dimensions change. 

I think I need to add a "resize" listener:

 

window.addEventListener("resize", () => {})

and collect the new widths with gsap.getPropoerty() after "resize" and tl.kill()?

But when I try this approach it doesn't work. 

 

Appreciate the help and feedback. 
M

 

See the Pen LYeYWXm by evryali (@evryali) on CodePen

Link to comment
Share on other sites

  • Solution

Hello there @pietM,

 

The jigsaw piece you're missing here is tl.invalidate()

https://greensock.com/docs/v3/GSAP/Timeline/invalidate()

Here's a demo, a little refactored - fromTo can sometimes be very useful, but it can also be unnecessary if you set things up properly in the CSS.

(also it's circ not cerc)

Hope this helps!

See the Pen OJzJmQN?editors=0010 by GreenSock (@GreenSock) 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...