Jump to content
Search Community

How to track element position when his parent is transformed.

wyy2 test
Moderator Tag

Recommended Posts

offsetLeft/Top don't include transforms. You can use getBoundingClientRect(), which includes transform.

 

However, getBoundingClientRect is axis aligned, so the rotated bounds might not be what you expect. Check out how the circle bounds changes.

 

See the Pen wRvjJL by osublake (@osublake) on CodePen

 

So it might be easier to use geBoundingClientRect on a point.

 

See the Pen 8b26bd5932fb8f6b9afb8d4131f8fd02 by osublake (@osublake) on CodePen

 

 

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