[英]Adding easing to the following jQuery animation?
I'm animating the height of element: 我正在动画元素的高度:
// Animate height of items
$j(".item .row").toggle(function(){
$j(this).animate({height:500},200);
},function(){
$j(this).animate({height:300},200);
});
I was wondering how to add easing to it? 我想知道如何增加宽松程度? (eg the animation slowing down towards the end?)
(例如,动画快慢到快结束了吗?)
Define easing, the following way 通过以下方式定义缓动
$('selector').animate({
prop:1
},{
easing: easing, //Something like 'linear'
duration: duration,
complete: callback
});
You can add other easing effects also, by including the Easing Plugin . 您还可以通过包含Easing Plugin添加其他缓动效果。
In your case, it would be something like 就您而言,它就像
$j(".item .row").toggle(function(){
$j(this).animate({height:500}, {
easing: 'linear',
duration: '200'
});
},function(){
$j(this).animate({height:300},{
easing: 'linear',
duration: '200'
});
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.