gpt4 book ai didi

jquery - 动画在 jQuery >1.4.x 中被破坏

转载 作者:行者123 更新时间:2023-12-01 06:02:15 25 4
gpt4 key购买 nike

为什么在包含最新的 jQuery 版本而不是 1.4.2 版本时,倒计时的翻转动画不起作用?

Animation demo

最佳答案

虽然我在发行说明中没有看到任何内容,但广泛的测试似乎表明,从 jQuery 1.5.0 及更高版本开始,您必须对 background-position-xbackground- 进行动画处理位置-y 单独。看这个问题:jquery animate background position

此代码适用于 jQuery 1.5.0:

// Animation function
function animateDigit(which, oldDigit, newDigit){
var speed = 80;
var pos = getPos(which, oldDigit);
var newPos = getPos(which, newDigit);
// Each animation is 5 frames long, and 103px down the background image.
// We delay each frame according to the speed above.
for (var k = 0; k < animationFrames; k++){
pos -= frameShift;
if (k == (animationFrames - 1)){
$("#" + which).delay(speed).animate({'background-position-y': pos + 'px'}, 0, function(){
// At end of animation, shift position to new digit.
$("#" + which).css({'background-position': '0 ' + newPos + 'px'}, 0);
});
}
else{
$("#" + which).delay(speed).animate({'background-position-y': pos + 'px'}, 0);
}
}
}

关于jquery - 动画在 jQuery >1.4.x 中被破坏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10149060/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com