寻找同步多个 nivo-slider 的功能

发布于 2024-11-10 19:01:37 字数 546 浏览 8 评论 0原文

我第一次在堆栈溢出上发帖,所以我希望有人能够帮助我解决这个问题:

我在一个页面上有 3 个 nivo-slider,水平排列。我希望它们能够同步,但更常见的是它们在几秒钟后就会失去同步。当所有滑块都使用此代码初始化时就是这种情况:

    $(window).load(function() {
     $('#slider').nivoSlider({
      animSpeed:500,         
      pauseTime:3000,         
     });
    });

但是,我想我可以像这样设置一个滑块,并使用参数设置另外两个滑块:

    manualAdvance:true,

然后

    beforeChange: function(){},

在第一个滑块上使用:来控制其他两个 - 将它们保持在同步。但是...我不确定在这里使用什么功能来转发其他滑块,我已经到处查看了,我真的很感谢您的帮助,提前致谢!

My first time posting on stack overflow so i'm hoping someone will be able to give me a hand with this problem:

I have 3 nivo-sliders on a page, lined up horizontally. I would like them to be synchronised but more often then not they fall out of sync after a few seconds. This is the case when all sliders are initialised with this code:

    $(window).load(function() {
     $('#slider').nivoSlider({
      animSpeed:500,         
      pauseTime:3000,         
     });
    });

However, I figured that I could set one slider up like this and another two with the parameter:

    manualAdvance:true,

and then use:

    beforeChange: function(){},

on the first slider to control the other two - keeping them in sync. However... I'm not sure what function to use here in order to forward the other sliders and I have looked EVERYWHERE, I really appreciate your help with this, thanks in advance!

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

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

发布评论

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

评论(2

桃酥萝莉 2024-11-17 19:01:37

这似乎没有在插件的核心中实现

,但您可以在 Nivo Slider v2.6 中自行添加它,

未压缩版本位于 start 和 stop 函数声明下方的第 633 行,

// Start / Stop
this.stop = function(){
    if(!$(element).data('nivo:vars').stop){
        $(element).data('nivo:vars').stop = true;
        trace('Stop Slider');
    }
}

this.start = function(){
    if($(element).data('nivo:vars').stop){
        $(element).data('nivo:vars').stop = false;
        trace('Start Slider');
    }
}

添加以下函数

//Manually run the slider
this.run = function() {
        nivoRun(slider, kids, settings, 'next');
}

您可以在包含更改后 。你可以使用它,就像

$('#slider').nivoSlider().data('nivoslider').run();

把它放在正确的事件中一样,你应该完成

This doesnt seem to be implemented in the core of the Plugin

but you may add it yourself

in Nivo Slider v2.6 the uncompressed version at line 633 just below the function declaration of start and stop

// Start / Stop
this.stop = function(){
    if(!$(element).data('nivo:vars').stop){
        $(element).data('nivo:vars').stop = true;
        trace('Stop Slider');
    }
}

this.start = function(){
    if($(element).data('nivo:vars').stop){
        $(element).data('nivo:vars').stop = false;
        trace('Start Slider');
    }
}

you may add the folowing function

//Manually run the slider
this.run = function() {
        nivoRun(slider, kids, settings, 'next');
}

after incldueing the changed .js and maybe compress it yourself (http://javascriptcompressor.com/) you may use it like

$('#slider').nivoSlider().data('nivoslider').run();

put this in the right event and you should be done

遮了一弯 2024-11-17 19:01:37

我想,设置暂停时间和 animSpeed 应该能让你的 nivo 滑块同步。

你说“更常见的是它们在几秒钟后失去同步”,是否有可能你有pauseOnHover:true并且你无意中将鼠标悬停在它们上并且它们变得不同步。可能是一个愚蠢的问题,但这发生在我身上。

Setting the pause time and animSpeed should get your nivo sliders in sync I would have thought.

You say "more often then not they fall out of sync after a few seconds", is it possible you have pauseOnHover: true and you are hovering over them inadvertantly and they are getting out of sync. May be a silly question but this has happened to me.

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