jQuery 旋转器,悬停在 div 和小缩略图导航上时暂停

发布于 2025-01-02 16:29:13 字数 504 浏览 3 评论 0原文

下面是我想要更新新功能的 jsfiddle.net 代码:

http://jsfiddle.net/weigruf/mKj8p /

我想添加的是当您将鼠标悬停在 .rotator .rotator-child div 上时序列上的暂停和一个小缩略图导航,它将显示同一图像的小版本,您可以导航通过他们。

此外,缩略图导航也应该具有暂停效果。

提前致谢。 (:

编辑1:

我组合了代码,并用 .mouseenter 更新了代码,现在序列已暂停,但是我想在 .mouseleave 上恢复序列,并在光标位于 div 上时再次暂停。

请看一下:

http://jsfiddle.net/weigruf/mKj8p/

Below is the jsfiddle.net code I want to update with new features:

http://jsfiddle.net/weigruf/mKj8p/

What I want to add is a pause on the sequence when you hover on .rotator .rotator-child div and a small thumbnail navigation that it will show a small version of the same image and you can navigate through them.

Also, the thumbnail navigation should have the pause effect as well.

Thanks in advance. (:

Edit 1:

I combined the codes and I updated the code with .mouseenter and now the sequence is paused, however I want to resume the sequence on .mouseleave and pause it again if the cursor is on the div.

Please take a look:

http://jsfiddle.net/weigruf/mKj8p/

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

百思不得你姐 2025-01-09 16:29:13

无论如何,我都不是 jQuery/JS 专家,这不是一个有效的示例,但这可能会帮助您指明正确的方向。

我没有使用 setTimeout,而是使用 setInterval。鼠标悬停时,清除间隔,这样它就不会再次触发。在 mouseleave 上,等待 6 秒,然后运行函数 doRotate(),该函数将再次重新启动计时器,并加载新广告。

function doRotate() {
    next();
    theInterval = setInterval(doRotate, 6000);
}

$('#myAdElement').mouseenter(function() {
   clearInterval(theInterval)
})

$('#myAdElement').mouseleave(function() {
   setTimeout(function() {
       doRotate();
   }, 6000);
})

I'm no jQuery/JS expert by any means, and this is not a working example, but this might help point you in the right direction.

Instead of setTimeout, I used setInterval. On mouseover, clear the interval so it doesn't fire again. On mouseleave, wait 6 seconds, and run the function doRotate() which will restart the timer again, and load the new ad.

function doRotate() {
    next();
    theInterval = setInterval(doRotate, 6000);
}

$('#myAdElement').mouseenter(function() {
   clearInterval(theInterval)
})

$('#myAdElement').mouseleave(function() {
   setTimeout(function() {
       doRotate();
   }, 6000);
})
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文