带有幻灯片效果的 jQuery UI 显示/隐藏 - 如何更改幻灯片“返回”速度
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17329533/
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 UI show / hide with a slide effect - how to change the slide "back-in" speed
提问by Dave
My page contains many OL lists, each showing a selection of links. When each link is clicked, content slides-out to the right. When clicking through each link, the content then slides back-in, then out again.
我的页面包含许多 OL 列表,每个列表都显示了一系列链接。单击每个链接时,内容会向右滑出。单击每个链接时,内容会滑回,然后再次滑出。
Here's a Fiddle showing this in action:
这是一个显示此操作的小提琴:
http://jsfiddle.net/juxprose/xu3ck/15/
http://jsfiddle.net/juxprose/xu3ck/15/
I would like to slow down the "back-in" part of the slide effect, so it matches the speed of the slide-out. You'll see currently it slides back-in very quickly - I'd like to adjust this speed.
我想减慢幻灯片效果的“后退”部分,使其与滑出的速度相匹配。你会看到它目前非常快速地滑回 - 我想调整这个速度。
Here's the JS part of the code, where the action happens:
这是代码的 JS 部分,动作发生的地方:
$('.trg-open.website-title').click(function (e) {
e.stopPropagation();
$('.website-info').hide();
$(this).next('.website-info').show('slide', {direction: 'left'}, 1400);
});
Any pointers gratefully appreciated, thanks.
任何指点,感激不尽,谢谢。
回答by Sushanth --
Try this instead of hiding it
试试这个而不是隐藏它
$(document).ready(function(){
$('.trg-open.website-title').click(function (e) {
e.stopPropagation();
$('.website-info').hide('slide', {direction: 'left'}, 1400);
$(this).next('.website-info').stop().show('slide', {direction: 'left'}, 1400);
});
});
回答by Balint Bako
How about $('.website-info').hide(1400)
? That will hide it with exact same speed as you are showing the stuff.
怎么样$('.website-info').hide(1400)
?这将以与您显示内容完全相同的速度隐藏它。
回答by Cheesi
$('.trg-open.website-title').click(function (e) {
e.stopPropagation();
$('.website-info').hide(1400); //You can set a duration-time in millisec ;)
$(this).next('.website-info').show('slide', {direction: 'left'}, 1400);
});