window.onload = (function () { var src = $("#image img")[0].src; $("#image").html(""); var R = Raphael("image", 600, 600), img = R.image(src, 140, 140, 320, 320), mouse; $(document).mousemove(function (e) { if (mouse) { img.rotate(e.pageX - mouse); } mouse = e.pageX; }); if ("orientation" in window) { var a = 0; document.ongesturechange = function (e) { var r = e.rotation % 360 - a; a += r; img.rotate(r); }; document.ongestureend = function () { a = 0; }; } });