我想使用 .animate() 在鼠标的 direction 中移动div,但是移动到另一个对象 . 因此,当移动到另一个div时,我希望对象在调用 .animate() 时传递光标所在的区域 .

我使用以下方法获取其他div的坐标:

$(this).offset().top - $(".target").offset().top * -1;

然后,我打电话给 .animate()

var dist = $(this).offset().top - $(".targer").offset().top * -1;
var angle = getAngle();
var x = Math.cos(angle*Math.PI/180) * dist;
var y = Math.sin(angle*Math.PI/180) * dist;
$(this).animate({'left': '+='+x+'px', 'top': '+='+y+'px'}, 2500);

当它移动时,我想要一个设置为鼠标方向的 var dir . 我该如何解决这个问题?我可以移动到鼠标,然后移动到目标,但缓动会让它看起来不自然 .

任何帮助表示赞赏 .