wyy2 Posted November 30, 2019 Share Posted November 30, 2019 I have a container which is moved, rotated and scaled. Is it possible to get a child of this container global position? In codepen example, blue target should point red circle. See the Pen QWwLrmm by wyy2 (@wyy2) on CodePen Link to comment Share on other sites More sharing options...
OSUblake Posted November 30, 2019 Share Posted November 30, 2019 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 5 Link to comment Share on other sites More sharing options...
wyy2 Posted December 1, 2019 Author Share Posted December 1, 2019 Wow, didn't expect it will be one line of magic Thanks! 2 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now