【发布时间】:2011-10-30 14:31:48
【问题描述】:
我能够将我的 <div> ( more info ) 从 bottom:-100px 设置为 bottom:0px 的动画。
现在我想要不同的速度:在动画开始时稍微慢一点,然后在动画结束时变快。
看起来是这样的:
$('#bannerFijo').animate({ bottom: '-15px' }, 1000, function() {
$('#bannerFijo').animate({ bottom: '0px' }, 100);
});
但我敢肯定,一定有另一种方式,让速度逐渐变化。
-编辑-
动画版二:
$('#bannerFijo').animate({ bottom: '0px' }, 1200, function() {
$('#bannerFijo').animate({ bottom: '-15px' }, 300,function() {
$('#bannerFijo').animate({ bottom: '-5px' }, 150,function() {
$('#bannerFijo').animate({ bottom: '-10px' }, 100,function() {
$('#bannerFijo').animate({ bottom: '0px' }, 50);
return true;
});
});
});
});
-编辑- 感谢 SuperPaperSam,我得到了这个解决方案(“没有”插件)
$.easing.easeOutBounce = function (x, t, b, c, d) {
if ((t/=d) < (1/2.75)) {
return c*(7.5625*t*t) + b;
} else if (t < (2/2.75)) {
return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
} else if (t < (2.5/2.75)) {
return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
} else {
return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
}
}
所以动画函数看起来像这样:
function mostrar_banner(){
$('#bannerFijo').animate({ bottom: '+=110px' }, 2000, 'easeOutBounce');
}
【问题讨论】:
标签: jquery jquery-animate effect