Jquery 获取作为animate方法中的properties参数传递的对象

Jquery 获取作为animate方法中的properties参数传递的对象,jquery,Jquery,对于包装在jquery对象中的dom元素,我需要获取当前位置,或者如果它当前正在设置动画,我需要获取其结束位置。在jquery.animate()方法中,是否有任何方法可以访问作为properties参数的对象过程?或者我需要将这些对象存储在某个地方,以便以后可以查找给定dom元素的动画位置?animate方法的标准参数之一是“complete”回调 在“complete”函数中,您可以通过在选择器中包装“this”来获取当前元素,如下所示: $("div").animate({ "w

对于包装在jquery对象中的dom元素,我需要获取当前位置,或者如果它当前正在设置动画,我需要获取其结束位置。在jquery.animate()方法中,是否有任何方法可以访问作为properties参数的对象过程?或者我需要将这些对象存储在某个地方,以便以后可以查找给定dom元素的动画位置?

animate方法的标准参数之一是“complete”回调

在“complete”函数中,您可以通过在选择器中包装“this”来获取当前元素,如下所示:

$("div").animate({
    "width": '500'
}, 3000, function() {
    $(this).css({"background-color":"black"});
});


还有一个“进度”函数,根据您的需要在每个步骤中调用。

找到了一种方法:

例如,如果我想将一个对象的动画设置为其当前位置的右侧50px,或者它要朝向的位置,我可以执行以下操作:

var currentX=myJqueryObject.css("left");//Get the position it's currently at
myJqueryObject.finish();//finish the animation so its position instantly gets set to where its animating towards
var endx=parseInt(myJqueryObject.css("left"));//get its position now. If it wasn't animating when finish() was called then the call didn't change anything.
myJqueryObject.css("left",currentX);//set its position back to where it was before calling finish()
myJqueryObject.animate({left:endx+50});//now animate it 50px to the right of its current position or 50px to the right of the position it was animating towards

不太确定你是否理解正确。我确实想出了一个解决办法,尽管我发布了