When changing the width/height of a rotated elements, the element moves!
Here's an example
JSFiddle
When I change the width for example, the object loses its original position, this is effecting jQueryUI Resizable and making it unusable.
CSS:
.test{
position: absolute;
top: 200px;
left; 200px;
width: 400px;
height: 200px;
background: red;
transform: rotate(-90deg);
}
JSFiddle
Is there a library or a function that corrects this issue by reversing this effect.
Edit: I made a jQuery function that corrects the top-left position upon resizing a rotated element, added as answer. Also this is a patch for jqueryui resizable
transform-origin
is set tocentre
by default, and when you change the width/height of the element, the original centre moves, thus moving your object.see this updated fiddle, with a fix for changing width http://jsfiddle.net/ww8k4hy4/6/EDIT
Set both values of
transform-origin
to be half of width -- see this: http://jsfiddle.net/ww8k4hy4/10/(figuring this out proved to be very helpful for me too, so thanks :) )
This jQuery function will change the size of the element and make necessary correction to preserve the top-left corner position
JSFiddle
Another useful function: