Jquery 的淡入淡出“慢”太快了
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4086710/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Jquery's fadein 'slow' is too fast
提问by Michel
i'm using the jquery fadein fadeout with the slow option, but it's still a little too fast for me. now i've read that you can only choose between fast and slow, but is there a way to make it slower?
我正在使用带有慢速选项的 jquery 淡入淡出,但它对我来说仍然有点太快了。现在我读到你只能在快和慢之间做出选择,但有没有办法让它变慢?
回答by lonesomeday
You have two options. The first is to use a number of milliseconds in the call:
你有两个选择。第一种是在调用中使用毫秒数:
$('#myItem').fadeOut(1500); // 1.5 seconds
The second option is to define a custom speed, or to redefine a jQuery native speed:
第二个选项是定义自定义速度,或重新定义 jQuery 原生速度:
$.fx.speeds.slow = 1500; // 'slow' now means 1.5 seconds
$.fx.speeds.xslow = 3000; // 'xslow' means 3 seconds
$.fx.speeds.xfast = 100; // 'xfast' means 0.1 seconds
You can then call them as normal:
然后您可以正常调用它们:
$('#myItem').fadeOut('slow');
$('#myItem').fadeOut('xslow');
$('#myItem').fadeOut('xfast');
This allows you to redefine speeds on an application-wide basis.
这允许您在应用程序范围的基础上重新定义速度。
回答by Fermin
Use a number of milliseconds rather than 'fast' or 'slow'
使用毫秒数而不是“快”或“慢”
e.g.
例如
$('#myID').fadeIn(100, function() {
// complete
});
回答by Justin Niessner
In addition to 'slow'/'fast', the fadeIn function also takes a timespan in milliseconds so you can make it take however long you want:
除了 'slow'/'fast' 之外,fadeIn 函数还需要以毫秒为单位的时间跨度,因此您可以根据需要让它花多长时间:
$('#someId').fadeIn(3000); // 3 second fade in
回答by Shawn31313
I really dont know how slow you want it but I recoomend something between 2500-4000
我真的不知道你想要多慢,但我建议在 2500-4000 之间
$('#Id').fadeIn(3500);
There we go
我们走了