I'm having a problem with getting the position of a div after rotate
filter is applied to it. I have the position of one end, its height, and the angle by which it is rotated, but after checking what this filter actually does on MDN ("[cos(angle) sin(angle) -sin(angle) cos(angle) 0 0]") I still don't know how to crack it.
Example :
The div I'm interested in is the dashed line. Its styling at that moment was :
left: 80px; top: 12px; height: 69.5122px; width: 2px; -moz-transform: rotate(-1.21366rad);
(top
/left
describe the position of its beginning.) I'm trying to get the top
/left
position of its end.
Per your current Question and your requested confirmation of:
The solution can be found in this other SO Answer for a different question, enhanced here:
Here's an interactive jsFiddle that provides real-time updates for
getPositionData();
function.You'll be able to see the
top
andleft
values at the end of the CSS3 Rotation process you control.Reference: jsFiddle
Status Update: The above jsFiddle works great for 0-90deg and can be approved upon for all angles and different units such as rad, grad, and turn.
Try using
element.getBoundingClientRect()
According to MDN: