简体   繁体   English

如何使用jQuery正确淡入和淡出?

[英]How do I properly fade in and out using jQuery?

Can anyone help me with this simple bit of jQuery? 谁能用这个简单的jQuery帮助我? I am building a carousel that features many sliding <li> s. 我正在构建具有许多滑动<li>的轮播。 Each one has a short description accompanying it, which I want to fade out when the carousel slides, and fade in when the carousel stops at another <li> . 每个人都有一个简短的说明,当圆盘传送带滑动时,我要淡出,而当圆盘传送带停在另一个<li>时,我要淡入。 The problem is that when the carousel controls are clicked rapidly, the fades take a while to catch up. 问题在于,当快速单击轮播控件时,渐变需要一段时间才能赶上。 Also the current simple fadeIn/Out option doesn't work well when clicking to an <li> much further through the carousel (from the small grey discs underneath infographic). 此外,当通过轮播(在信息图下方的小灰色光盘中)单击更远的<li>时,当前的简单fadeIn / Out选项也无法正常工作。 I've tried a few options but I'm not really getting anywhere. 我已经尝试了几种选择,但是我什么都没有。

The page is here: http://weaver-wp.weavertest.com/radiation-infographic/ 页面在这里: http : //weaver-wp.weavertest.com/radiation-infographic/

Thanks for any help :) 谢谢你的帮助 :)

David 大卫

The trick is to stop the operation before you start the next one: 诀窍是在开始下一个操作之前先停止操作:

http://api.jquery.com/stop/ http://api.jquery.com/stop/

bottom line, you stop all previous animations before you call in the next one. 最重要的是,您停止所有先前的动画,然后再调用下一个。 This avoids building up a queue of animations. 这避免了建立动画队列。

在调用fadeIn / fadeOut之前使用clearQueue

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM