Jump to content
Search Community

Layout shift after Flip animation completes

Evoke Canale test
Moderator Tag

Go to solution Solved by Rodrigo,

Recommended Posts

I'm trying to create a Flip animation that swaps grid items on click.  I am basing it off of this GSAP demo: 

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

 

 

The Flip animation completes fine, but then all of the grid items move and then shift back to their correct position.  I've tried using both absolute: true and absolute: false.  absolute: true provides the smooth animation but has the shift after it completes.  absolute: false has a jerky animation, but no shift after it complete.

 

I've created a minimal demo here:  

 

Thank you for any help! 

See the Pen bGJaQZq by canalecomm_dev (@canalecomm_dev) on CodePen

Link to comment
Share on other sites

  • Solution

Hi,

 

This happens because you have this on your CSS:

.grid-tile {
  box-sizing: border-box;
  border-radius: 1em;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5em;
  overflow: hidden;
  transition: 0.6s ease-out all; /* <- HERE */
  background-color: darkseagreen;
}

That transition all kicks in after Flips handles all it's magic. If you comment that out everything seems to work as expected:

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

 

Word of advice: NEVER use transition all in your css, that could lead to unexpected problems like this 😉

 

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