我遇到了问题。
我有一个正在修改的脚本。一切都运行良好,但仅在 jQuery 1.4.4 上。当我升级版本时,假设最新版本(1.7.2)脚本将无法运行。是什么赋予了?!
var bouncespeed = 450;
function bounce(currentA) {
newx = Math.floor(10 * Math.random());
newy = Math.floor(3 * Math.random());
newspeed = bouncespeed + Math.floor(10 * Math.random());
$(currentA).animate({
backgroundPosition: newx + 'px ' + newy + 'px'
}, newspeed, 'linear', function() {
bounce(currentA);
});
}
$('.bubble').each(
function() {
$(this).css({
backgroundPosition: '5px 5px'
});
bounce(this);
});
游玩时间!:http://jsfiddle.net/mdecler/rgBeW/2/
这是一个已记录的错误(http://bugs.jquery.com/ticket/8160)从 1.5 版本开始影响 jQuery。所以实际上没有办法在 jQuery 1.7.2 上为该属性设置动画
你可以改为使用.css()
而不是 animate 然后调用具有较小超时的函数,但效果不会很流畅
否则做一个动画div
本身,改变他们的margin-top/left properties
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)