I am working on a project in which i want to drag, rotate and resize images. This is my first jquery project and so far things are working ok. Trough stackoverflow i found the plugin jqueryrotate which handles the rotation.
The problem is that i now have an image which i can drag around and rotate but when i try to resize a rotated image, i get some funny results. The resizing after the rotation seems off.
HTML
<script type="text/javascript" src="http://jqueryrotate.googlecode.com/files/jQueryRotate.2.1.js"></script>
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
<img id="resizableImage0" class="resize" width="100px" height="100px" alt="tile0" src="http://www.elaxtro.com/images/demo.png">
<img id="resizableImage1" class="resize" width="100px" height="100px" alt="tile1" src="http://www.specialized.com/OA_MEDIA/2009/bikes/9397-20_demo8_2_ano_blue_d.jpg">
jQuery
window.zindex = 30;
$(document).ready(function() {
$(".resize").resizable();
$(".resize").parent().draggable({
stack: "div"
});
$(".resize").rotate({
bind: {
dblclick: function() {
// get current
var currentAngle = $(this).get(0).Wilq32.PhotoEffect._angle;
var newAngle = currentAngle + 90;
$(this).rotate(newAngle);
}
}
});
});
The fiddle should make things clear. Fiddle
Doubleclicking rotates an image 90 degrees :)
Is there anyone who can help me with this.
Thank you in advance.
Edit: fixed the resizer in the fiddle example Please note that the problem is best visible if you rotate once so that the image is 90 degrees rotated. After this try to resize.
The problem does not occur when an image is 0 degrees or 180 degrees rotated