Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

How to get new position after transform? Can anybody please help me to do that.

I used

$('#text').css('-moz-transform','rotate(90deg)');

Now I want to get left and right postion.

When I try to get left and top position it shows left and top position before transform

$('#text').position().left;    
$('#text').position().top;

It shows position before div transform

I want to get the new position. How do i do that?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
258 views
Welcome To Ask or Share your Answers For Others

1 Answer

I am trying to solve this issue as well. What the user is saying is this:

Let's say you have a div that is 300px by 200px and the top and left position is: 100, 100.

If you rotate it from the center, the top and left positions of the div has now changed, yet Mozilla still returns the pre-rotated top/left positions. Chrome actually returns the correct values after rotation, but FireFox does not.

If you inspect the element with FireBug, the highlighted area is the div also pre-rotation. So there doesn't appear to be any normal way to get the top and left positions after rotating, unless there is some kind of formula that could calculate it based on the height and width and the angle.

Does anyone know of such a formula, or another way to solve this issue?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...