Jump to content
Search Community

Animate div width from center

Daniel Hult 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

Hi!

How can I make a div go from 0 to 100% width, and also from the center? I don't want to scale the whole thing - I just want it to animate the width.

Also just wanted to say that I am super happy with both the products and the support here is amazing! Thank you guys for such a good product and community :)

  • Like 1
  • Thanks 2
Link to comment
Share on other sites

1 hour ago, Daniel Hult said:

Also just wanted to say that I am super happy with both the products and the support here is amazing! Thank you guys for such a good product and community :)

Love hearing that!

 

@mikel offered a great solution. Here's another example of basically the same idea: 

See the Pen 8586b002d06797032bb34a647adc01b2 by GreenSock (@GreenSock) on CodePen

  • Like 1
Link to comment
Share on other sites

26 minutes ago, Daniel Hult said:

Why does the svg logo behave so weird? Like flickering?

Short answer: its container is being moved and changing width so it's hard for the browser to properly calculate the position of the element.

 

I'd recommend placing it outside of the background that's animating.

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