Jump to content
Search Community

I can't center a DIV

delizade 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

That's because you're using percentage-based transforms that are set only in the CSS, but the browser reports the computed values in pixels (a matrix() or matrix3d()), so GSAP can't discern that you intended percentages. When you do a rotation (or any transform), those computed values got baked into the matrix()/matrix3d(). We strongly recommend that you always set transform values via GSAP because not only does it perform better, but it also ensures that your intent is clearly communicated and that rotational values beyond 360 degrees remain accurate (matrix math doesn't permit that). 

 

Just use GSAP's xPercent and yPercent. Here's a reworked fork of your demo: 

See the Pen ?editors=0010 by GreenSock (@GreenSock) on CodePen

 

Better?

 

Happy tweening!

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