I have the following function which rotates an image
function rotateImage(offsetSelector, xCoordinate, yCoordinate, imageSelector){
var x = xCoordinate - offsetSelector.offset().left - offsetSelector.width()/2;
var y = -1*(yCoordinate - offsetSelector.offset().top - offsetSelector.height()/2);
var theta = Math.atan2(y,x)*(180/Math.PI);
var rotate = 'rotate(' + theta + 'deg)';
imageSelector.css('-moz-transform', rotate);
}
However when I call it the following way it only executes once upon a mousedown.
$('#someImage').on('mousedown', function(event){
rotateImage($(this).parent(), event.pageX,event.pageY, $(this));
});
My intent is for the image to rotate while it’s being grabbed and until the user lets go of the mouse click. Is there a simple way to do this without the use of external libraries?
Example: