Jump to content
Search Community

Trying to Animate to open div from middle & the animation to be vice versa

Syed Azam test
Moderator Tag

Recommended Posts

I would not nest your elements, because if you do the parent shape needs to be visible to show the child shapes. 

 

So what I've done is moved your `.bg`'s to to the top level and add `position: absolute;` to them to have them all stack on top of each other. You could target each `.bg` individually, but this is the perfect use case for Stagger (see the docs for an overview). I also find it easier to animate .from(), because if your elements are already positioned at their end state, you can just to a .from() tween to get them to animate without any other code. At last I animate `scaleX` instead of `width` this is more perforated and easier to have them animate form the center, oh and I added a `defaults:{}` property to your timeline with a `transformOrigin: "center center"` to have all the elements animate from their center position.

 

See the Pen qBovGQY?editors=0100 by mvaneijgen (@mvaneijgen) on CodePen

 

Good luck!

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