jcarousellite 点击停止
你好 我有一个包含 jcarousellite 的页面,显示一些图像并每 5 秒自动滚动一次,当我单击轮播中的任何图像时,我想停止滚动,
这就是我想要做的
$(document).ready(function() {
$('.slider_images').jCarouselLite({
btnNext: "#next",
btnPrev: "#prev",
auto: 3000
});
$(".slider_images img").click(function(){
$('.slider_images').jCarouselLite({
btnNext: "#next",
btnPrev: "#prev",
scroll: false
});
});
});
hi
i have a page with jcarousellite showing some images and scrolling auto after every 5 seconds i want to stop the scroll when i click on any image in carousel
here is what i am trying to do
$(document).ready(function() {
$('.slider_images').jCarouselLite({
btnNext: "#next",
btnPrev: "#prev",
auto: 3000
});
$(".slider_images img").click(function(){
$('.slider_images').jCarouselLite({
btnNext: "#next",
btnPrev: "#prev",
scroll: false
});
});
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
我很抱歉这么晚才回复。我的问题解决了。我们可以通过改变jcarousellite的pauseOnHover选项很容易地实现点击停止属性。如果你看到pauseOnHover的实现,它是这样的:
我们可以通过将ul.hover更改为ul.click来实现点击停止
。祝你有美好的一天。
I am so sorry for very late response. My problem was solved. We can achieve stop on click property very easily by changing pauseOnHover option of jcarousellite. If you see the implementation of pauseOnHover, its something like this:
we can achieve stop on click by changing ul.hover to ul.click
Have a Nice Day.
我读了一会儿代码,发现自动滚动是通过使用
setTimeout
实现的:如果你第二次使用
jCarouselLite
,它不会停止>设置超时
。要停止setTimout
,您必须调用window.clearTimeout
:这是不可能的,因为 jcarousel 的代码没有为您提供这些
timeoutId
。您可以与开发人员交谈或自行修改代码。i read the code for a while and found out that the auto scrolling is implemented by using a
setTimeout
:If you use
jCarouselLite
a second time it won't stop thesetTimeout
. To stop asetTimout
you have to invokewindow.clearTimeout
:This is impossible since the code of jcarousel didn't provide you with these
timeoutId
. You can talk to the developer or modify the code on your own.我想不同意 scheffield 和/或找到使用此插件的解决方案,但我必须同意他的观点- 需要重写源代码才能完成您想要的操作。或者,您可能需要考虑 jquery 循环。它已经有“暂停”和“停止”方法。
I wanted to disagree with scheffield and/or find a work around using this plug-in, but I have to agree with him - it would take a rewriting of the source to do what you wanted. Alternatively, you may want to consider jquery cycle. It has 'pause' and 'stop' methods already there.
的顶部
将其添加到文件更改
以
停止滚动
Add this to the top of the file
change
to
to stop a scroll
这将停止页面上的所有轮播自动前进。我正在杀死这里使用超时的所有内容。这对我有用:
This will stop all carousels auto progression on the page. I am killing everything that is using a timeout here. This worked for me:
如果您使用的是最新的 jcarousel https://github.com/kswedberg/jquery-carousel- lite/
由于某种原因,此事件不在他们的文档中,尽管暂停Carousel 是。
If you're using the newest jcarousel https://github.com/kswedberg/jquery-carousel-lite/
This event isn't in their documentation for some reason although pauseCarousel is.