Bootstrap Carousel v2.0.4在mouseleave事件中重新启动 [英] Bootstrap Carousel v2.0.4 restarts on mouseleave event

查看:72
本文介绍了Bootstrap Carousel v2.0.4在mouseleave事件中重新启动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

jQuery v 1.7.2,
Bootstrap v 2.0.4(今天早上从主页下载了标准文件)

jQuery v 1.7.2, Bootstrap v 2.0.4 (downloaded standard file from homepage this morning)

<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<script>$('#myCarousel').carousel({interval: false})</script>

我见过很多与此有关的问题,但根据官方的Bootstrap博客( Javascript标题下的第5和第10条),此问题应该在v2.0.3中解决。

I've seen lots of questions about this but according to the official Bootstrap blog (items 5 and 10 under the heading 'Javascript'), this issue was supposed to be resolved in v2.0.3.

我在通话中添加了一个false间隔,因为这应该(根据文档)防止滑动,除非用户单击上一个/下一个链接

I've added an interval false to the call, since this is supposed to (according to the docs) prevent it from sliding unless the user clicks the prev/next links.

起初,这很好用:页面加载,无滑动,用户单击下一个链接,很好地过渡到下一个幻灯片。但是,如果用户将鼠标从容器#myCarousel移开,则滑动动作将再次开始自动执行。

At first this works fine: page loads, no sliding, user clicks next link, transitions nicely to the next slide. But if the user moves the mouse away from the container #myCarousel, then the sliding action starts automating again.

这是怎么回事?我真的希望该滑动动作受用户控制。

What's going on? I would really like the slide action to be under user control.

推荐答案

我无法重新创建您描述的行为。

I was unable to recreate the behavior that you described.

如果您确实看到此行为,则应在 Bootstrap存储库中报告问题。 a>。

If you really are seeing this behavior you should report an issue on the Bootstrap repo.

也就是说,如果您要完全禁用基于悬停的暂停切换,请尝试使用

That said, if you want to disable the hover-based pause toggling altogether, try using

$('#myCarousel').carousel({interval: 0, pause: 'none'});

暂停的值必须是悬停 以外的任何值。 interval 的值只是虚假的,我认为使用 0 在语义上更有意义,因为它被认为是

That value for pause just needs to be anything other than 'hover'. The value for interval just needs to be falsy, and I think using 0 makes more sense semantically, since it is supposed to be a Number otherwise.

另一种方法是手动关闭鼠标侦听器:

Another option is manually switching off the mouse listeners:

$('#myCarousel').off('mouseenter').off('mouseleave');

这篇关于Bootstrap Carousel v2.0.4在mouseleave事件中重新启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆