I have an image (little airplane) and I want the plane to rotate facing mouse pointer. I found some scripts to do that but I can get it to work with Hype. Iām more a designer! Could someone help me rewrite the script for Hype.
This is the script:
var box=$(".box");
var boxCenter=[box.offset().left+box.width()/2, box.offset().top+box.height()/2];
$(document).mousemove(function(e){
var angle = Math.atan2(e.pageX- boxCenter[0],- (e.pageY- boxCenter[1]) )*(180/Math.PI);
box.css({ "-webkit-transform": 'rotate(' + angle + 'deg)'});
box.css({ '-moz-transform': 'rotate(' + angle + 'deg)'});
box.css({ 'transform': 'rotate(' + angle + 'deg)'});
});
Example:
http://jsfiddle.net/opherv/ddGHz/
Thanks