JQuery 循环 - 淡入/淡出中断
我有一个 JQuery 幻灯片,其中一些文本/幻灯片淡入淡出。
同时我有一个导航/点击点。当您单击某个位置时,幻灯片/文本会发生变化。
问题是当文本/幻灯片淡入淡出并且用户单击某个位置时,淡入淡出会中断。如果用户快速单击所有点,则会同时显示来自不同幻灯片的文本。
我希望淡出结束,然后用户可以单击。简而言之:当淡入淡出时没有点击。
我做了一个小例子来说明这个问题。
html 的头部部分:
<style type="text/css">
.slideshow
{
width:600px;
height:30px;
background-color:#0FF;
overflow:hidden;
margin:50px;
}
.slideshow_text_font
{
font:Verdana, Geneva, sans-serif;
font-size:22px;
font-weight:bold;
}
</style>
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery.cycle.all.latest.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('.slideshow').cycle({
fx: 'custom',
sync: 0,
cssBefore: {
opacity:0,
display: 'block'
},
animIn: {
opacity:1
},
animOut: {
opacity:0
},
timeout:5000,
speed:2000
});
});
if (document.images) {
function setSlide(index) {
$('.slideshow').cycle(index);
}
}
</script>
html 的主体部分:
<div class="slideshow">
<div><a class="slideshow_text_font">1. Some text for slide number one</a></div>
<div><a class="slideshow_text_font">2. Lorem Ipsum is simply dummy text of the</a></div>
<div><a class="slideshow_text_font">3. Contrary to popular belief, Lorem Ipsum</a></div>
<div><a class="slideshow_text_font">4. The standard chunk of Lorem Ipsum used</a></div>
<div><a class="slideshow_text_font">5. It is a long established fact that a</a></div>
<div><a class="slideshow_text_font">6. There are many variations of passages</a></div>
</div>
<div>
<a class="slideshow_text_font" onclick="setSlide(0)">Show slide 01</a><br />
<a class="slideshow_text_font" onclick="setSlide(1)">Show slide 02</a><br />
<a class="slideshow_text_font" onclick="setSlide(2)">Show slide 03</a><br />
<a class="slideshow_text_font" onclick="setSlide(3)">Show slide 04</a><br />
<a class="slideshow_text_font" onclick="setSlide(4)">Show slide 05</a><br />
<a class="slideshow_text_font" onclick="setSlide(5)">Show slide 06</a>
</div>
I have a JQuery slideshow where some text/slide fades in and out.
At the same time I have a navigation/spots to click. When you click on a spot the slide/text changes.
The problem is when the text/slide is fading and the user clicks on a spot, the fading is interrupted. And if the user clicks on all the spots fast, then there is text from different slides that is shown at the same time.
I want the fading to end and then the users can click. In short: when fading no click.
I have made a little example that shows the problem.
Head-part of the html:
<style type="text/css">
.slideshow
{
width:600px;
height:30px;
background-color:#0FF;
overflow:hidden;
margin:50px;
}
.slideshow_text_font
{
font:Verdana, Geneva, sans-serif;
font-size:22px;
font-weight:bold;
}
</style>
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery.cycle.all.latest.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('.slideshow').cycle({
fx: 'custom',
sync: 0,
cssBefore: {
opacity:0,
display: 'block'
},
animIn: {
opacity:1
},
animOut: {
opacity:0
},
timeout:5000,
speed:2000
});
});
if (document.images) {
function setSlide(index) {
$('.slideshow').cycle(index);
}
}
</script>
Body-part of the html:
<div class="slideshow">
<div><a class="slideshow_text_font">1. Some text for slide number one</a></div>
<div><a class="slideshow_text_font">2. Lorem Ipsum is simply dummy text of the</a></div>
<div><a class="slideshow_text_font">3. Contrary to popular belief, Lorem Ipsum</a></div>
<div><a class="slideshow_text_font">4. The standard chunk of Lorem Ipsum used</a></div>
<div><a class="slideshow_text_font">5. It is a long established fact that a</a></div>
<div><a class="slideshow_text_font">6. There are many variations of passages</a></div>
</div>
<div>
<a class="slideshow_text_font" onclick="setSlide(0)">Show slide 01</a><br />
<a class="slideshow_text_font" onclick="setSlide(1)">Show slide 02</a><br />
<a class="slideshow_text_font" onclick="setSlide(2)">Show slide 03</a><br />
<a class="slideshow_text_font" onclick="setSlide(3)">Show slide 04</a><br />
<a class="slideshow_text_font" onclick="setSlide(4)">Show slide 05</a><br />
<a class="slideshow_text_font" onclick="setSlide(5)">Show slide 06</a>
</div>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用添加此插件代码来阻止所有点击:
要开始阻止所有点击,请在链接时使用
.blockClicks()
,或者仅使用$.blockClicks();
停止阻止点击,只需发送false
:请参阅此jsfiddle 进行演示。
You could use add this plugin code to block all clicks:
To start blocking all clicks, use
.blockClicks()
while chaining, or just use$.blockClicks();
To stop blocking clicks, just sendfalse
:See this jsfiddle for a demonstration.
尝试将
prevNextEvent
设置为null
。Try setting
prevNextEvent
tonull
.