-1
我想知道如何更改圖像所在的X和Y座標。因此,如果有人按下任何箭頭鍵,圖像將相應地移動。 (以及根據鼠標位置旋轉的圖像)更改圖像的x和y線
$(function() {
var img = $('.image');
var offset = img.offset();
var value = 200;
function mouse(e) {
var centerX = (offset.left) + (img.width()/2);
var centerY = (offset.top) + (img.height()/2);
var mouse_x = e.pageX; var mouse_y = e.pageY;
var radians = Math.atan2(mouse_x - centerX, mouse_y - centerY);
var degree = (radians * (180/Math.PI) * -1) + 90;
img.css('-webkit-transform', 'rotate(' + degree + 'deg)');
}
$(document).mousemove(mouse);
});