iosscripts / iosslider

iosslider is a jQuery plugin which allows you to integrate a customizable, cross-browser content slider into your web presence. Designed for use as a content slider, website banner, or image gallery.
http://iosscripts.com/iosslider
432 stars 103 forks source link

Dynamic slides, .iosSlider('update') and autoSlide + Meteor.js #346

Open snshn opened 10 years ago

snshn commented 10 years ago

There's a slight modification I'd like to suggest around line 985:

            if(!iosSliderSettings[sliderNumber].autoSlide) return false;

            if( slideNodes.length < 2 ) {
                // clear the timeouts from the previous set of nodes
                for(var j = 0; j < scrollTimeouts.length; j++) {
                    clearTimeout(scrollTimeouts[j]);
                }
            }

this prevents the slider from scrolling to non-existent slides if switched from 3 slides to 2 dynamically via .iosSlider('update');. The "for()" loop takes care of the dots on the bottom to behave properly.

I'm using Meteor.js so here's part of my code where I re-apply the settings which aren't being remembered btween the 'updates':

    Meteor.setTimeout(function(){
      var $el = $('.iosSlider');
      $el.data('iosslider').settings.infiniteSlider = true;
      $el.data('iosslider').settings.autoSlide = true;
      $el.iosSlider('update');
    }, 200);

I have to re-apply those settings for returning from 1-node to mutli-node sliders. Meteor's engine (blaze) dynamically changes the amount of slides (.item) within the DOM. So I have to call that update thingy.

Danks.

snshn commented 10 years ago

Seems to be causing an infinite loop which hangs the browser after some time. I'm still looking for a solution to terminate the autoSlide for 1-node sliders upon update.