-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);
});