如何在bxslider中的幻灯片之间指定不同的延迟 [英] How to specify different delays between slides in bxslider

查看:109
本文介绍了如何在bxslider中的幻灯片之间指定不同的延迟的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在bxslider中遇到以下问题-如何在自动放映的幻灯片之间应用不同的延迟?

Ran across the following problem in bxslider- how can you apply different delays between slides in the auto show?

推荐答案

I提出了以下解决方案,我将在此处显示:

I came up with the following solution which I will show here:

在jquery.bxslider.js中替换:

in the jquery.bxslider.js replace:

 el.startAuto = function(preventControlUpdate){
        // if an interval already exists, disregard call
        if(slider.interval) return;
        // create an interval
        slider.interval = setInterval(function(){
            slider.settings.autoDirection == 'next' ? el.goToNextSlide() : el.goToPrevSlide();
        }, slider.settings.pause);
        // if auto controls are displayed and preventControlUpdate is not true
        if (slider.settings.autoControls && preventControlUpdate != true) updateAutoControls('stop');
    }

     /**EDITS: By CRB - techdude **/
    el.startAuto = function(preventControlUpdate){
        el.continueAuto();
    }

    el.continueAuto = function(){
        //get how long the current slide should stay
        var duration = slider.children.eq(parseInt(slider.active.index)).attr("duration");
        if(duration == ""){
            duration = slider.settings.pause;
        } else {
            duration = parseInt(duration);
        }
        console.log(duration);

        // create a timeout
        slider.timer = setTimeout(function(){
            slider.settings.autoDirection == 'next' ? el.goToNextSlide() : el.goToPrevSlide();
            el.continueAuto();
        }, duration);
        // if auto controls are displayed and preventControlUpdate is not true
        if (slider.settings.autoControls && preventControlUpdate != true) updateAutoControls('stop');

    }

    //*End Edits*/

然后要更改幻灯片的持续时间,只需为其li标签赋予一个duration属性,例如:
,其中duration是幻灯片暂停的毫秒数。

Then to change the duration of a slide, simply give its li tag a duration attribute like this: where duration is the number of milliseconds for the slide to pause.

要设置默认持续时间,只需在设置中使用pause:选项:

To set the default duration, simply use the pause: option in the settings:

$("element").bxSlider({
  auto:true,
  pause: 4000
};

希望这会有所帮助。也许bx滑块甚至会将其添加到以后的版本中。:)

Hope this helps. Maybe bx slider will even add it to a future version. :)

这篇关于如何在bxslider中的幻灯片之间指定不同的延迟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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