更新时间:2023-10-28 12:40:28
编辑
从css3开始,不使用.animate进行简单动画 - Kluska000
"I'm not using .animate for simple animations since css3. – Kluska000"
应该仍然能够使用jquery的 ()
开始
,步骤
,进度
回调函数 - 即使实际动画在 css
完成。例如,可以在目标元素中使用 .animate()
- 实际上不对元素进行动画处理 - 仅使用 start
code> step , progress
回调函数; duration
同步到 css
动画持续时间。此外,看起来jquery .animate()
实际上并不要求目标是 DOM
元素;可以是2 js objects
。
Should still be able to utilize jquery's animate()
start
, step
, progress
callback functions - even though actual animation done at css
. e.g., could utilize .animate()
at target element - without actually animating the element - only to utilize start
, step
, progress
callback functions; with duration
synced to css
animations duration . Also, appear that jquery .animate()
does not actually require that a target be a DOM
element; could be 2 js objects
.
另请参阅 window.requestAnimationFrame()
https://developer.mozilla.org/en-US/docs /Web/API/window.requestAnimationFrame
http://www.paulirish.com/2011/requestanimationframe-for-smart-animating/
尝试 console
在jsfiddle,下面链接)
Try (see console
at jsfiddle, linked below)
$(function() {
$(".mydiv").animate({
left :"0px"
}, {
duration : 1234,
start : function (promise) {
console.log($(".mydiv").position().left);
},
step : function (now, tween) {
console.log($(".mydiv").position().left);
},
progress : function (promise) {
console.log($(".mydiv").position().left);
},
complete : function () {
$(this).animate({left:"0px"}, 1234)
}
});
});
jsfiddle http://jsfiddle.net/guest271314/xwL7v/
jsfiddle http://jsfiddle.net/guest271314/xwL7v/
查看 http://api.jquery.com/animate/ 在开始
,步骤
, progress