How to make step carousel wrap around and then stop on slide #1

那年仲夏 提交于 2019-12-08 04:55:50

问题


So I am using this example of the dynamic carousel and I am trying to configure the javascript to allow the it to scroll through once but then start over and stop on slide #1: here is the website: http://www.dynamicdrive.com/dynamicindex4/stepcarousel.htm

I have tries to change the autostep parameter from true to false but that either loops forever or stops on the last one.

I tried to use the: onslide:function()

but I cannot figure out the syntax to determine how the slider knows what the last slide is.

Can anyone help me with this?


回答1:


The answer is posted here: http://www.dynamicdrive.com/forums/showthread.php?t=67842

but here is the code:

<script type="text/javascript">

stepcarousel.setup({
    galleryid: 'mygallery', //id of carousel DIV
    beltclass: 'belt', //class of inner "belt" DIV containing all the panel DIVs
    panelclass: 'panel', //class of panel DIVs each holding content
    autostep: {enable:true, moveby:1, pause:3000},
    panelbehavior: {speed:500, wraparound:false, wrapbehavior:'slide', persist:false},
    defaultbuttons: {enable: true, moveby: 1, leftnav: ['10/leftnav.gif', -5, 80], rightnav: ['10/rightnav.gif', -20, 80]},
    statusvars: ['statusA', 'statusB', 'statusC'], //register 3 variables that contain current panel (start), current panel (last), and total panels
    contenttype: ['inline'], //content setting ['inline'] or ['ajax', 'path_to_external_file']
    **onslide: function(){
        var id = 'mygallery', car = stepcarousel.configholder[id];
        if(car.currentpanel == car.lastvisiblepanel && !car.hasstopped){ //if we're at the end
            setTimeout(function(){stepcarousel.stepTo(id, 1);}, car.autostep.pause); //step one more time
            car.onslide = function(){}; //and stop checking
        }
    }**
})

</script>

Then you also have to change the stepcarousel.js from:

stopautostep:function(config){
        clearTimeout(config.steptimer)
    },

to:

stopautostep:function(config){
    clearTimeout(config.steptimer);
    config.hasstopped = true;
},

Cannot Thank John enough for helping me with this, hope it helps anyone else.



来源:https://stackoverflow.com/questions/9589477/how-to-make-step-carousel-wrap-around-and-then-stop-on-slide-1

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!