[英]How to change site-wide jQuery slideUp/slideDown duration?
Is there a way to adjust the default slideUp() and slideDown() duration in jQuery? 有没有办法在jQuery中调整默认的slideUp()和slideDown()持续时间? I have a site which has a bunch of slideUp/slideDown calls and I'd like to change their duration site-wide. 我有一个网站有一堆slideUp / slideDown调用,我想在网站范围内更改他们的持续时间。 The only options I can find: 我能找到的唯一选择:
You can change the default animation speed like this: 您可以像这样更改默认动画速度:
$.fx.speeds._default = 1000;
Important Note: I think this will change the default speed for every jQuery animation, which may not be ideal in this case. 重要说明:我认为这将改变每个jQuery动画的默认速度,在这种情况下可能不是理想的。
You could override them like: 您可以覆盖它们,如:
$.prototype.slideDown = (function(slideDown){
var defaultSpeed = 2000;
return function(speed){
slideDown.call( this, speed || defaultSpeed );
};
})($.prototype.slideDown);
Then just do the same with the slideup function: 然后用幻灯片功能做同样的事情:
$.prototype.slideUp = (function(slideUp){
var defaultSpeed = 2000;
return function(speed){
slideUp.call( this, speed || defaultSpeed );
};
})($.prototype.slideUp);
Then just call it: 然后就叫它:
$('#whatever').slideUp();
Just make sure to override them before you start using them. 只需确保在开始使用它们之前覆盖它们。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.