Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
Clemorphy

X and Y relative to transformOrigin

Recommended Posts

Hi

 

I am just not sure if x and y properties are supposed to be relative to transformOrigin.

 

Let's say I have a simple div, width 200px, height 200px.

 

If I am right, by default, transformOrigin is set to "50% 50% 0".

 

So if I rotate my div, the rotation is relative to its center. Fine.

 

But if I set x and y properties of my div (with TweenMax.set()), the position is always relative to its top left corner, and not to its transformOrigin.

 

1) is it the expected behaviour ?

 

2) if yes, is there a way to change the origin point for x and y properties ? Without having to set margin-left : -100px and margin-top : -100px

 

Thanx.

Link to comment
Share on other sites

Hello Clemorphy, and Welcome to the GreenSock forum!

 

When i animate x and y .. i do not see how the transform-origin changes. It is still 50% 50% like when it is rotating

 

See the Pen ORLAmW by jonathan (@jonathan) on CodePen

 

Now i can see how transform-origin would change if you were doing a whole mess of rotations within nested elements. But the behavior should be the same whether it is animated with CSS transitions / animations or via JS. ;)

 

If you are still having an issue, please provide a codepen demo example showing your issue so we can help you better.

 

Resource:

CSS transform-origin: https://developer.mozilla.org/en-US/docs/Web/CSS/transform-origin

 

Thanks :)

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