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

Browser Freeze when no slides are defined #338

Open lowedown opened 10 years ago

lowedown commented 10 years ago

This line in slowScrollHorizontalInterval leads to an infinite loop when sliderMax[sliderNumber] is 0 and newOffset is 0 causing the browser to freeze.

while(newOffset <= (sliderMax[sliderNumber] * -1)) {

This would happen, when we didn't have any slides defined.

marcwhitbread commented 10 years ago

So you are initializing a slider with no slides?

lowedown commented 10 years ago

That's one scenario when it happened. We made sure that we always have slides defined, but it would also happen sometimes with slides... possibly because our CMS injects some markup. I couldn't exactly figure out why it happens, because the browser always hangs, but if an infinite loop would be prevented, the problem would be solved.

marcwhitbread commented 10 years ago

Thanks for the info. I will take a look at it.

reynoldsalceda commented 9 years ago

For emtpy slides, may be you can apply this workaround:

if($('.iosslider li.slide').length>0){
    //initialize slider here
    $('.iosslider').iosSlider()
}

I am also having the browser freezing issue when I set the slider's style to display:none for mobile as client wants it that way.

@media screen and (max-width: 479px){
    div#featured-wrapper.iosslider{
        display:none!important
    }
}

So for those who might stumble into similar case, I have initialized the slider like this to fix the issue:

function initHomeSlider() {
    jQuery('.iosslider:hidden').iosSlider('autoSlidePause');        
    jQuery('.iosslider:visible').iosSlider({
        snapToChildren: true,
        desktopClickDrag: true,
        infiniteSlider: true,
        snapSlideCenter: true,
        navNextSelector: jQuery('.next'),
        navPrevSelector: jQuery('.prev'),
        autoSlide: true,
        autoSlideTimer: 5000,
        autoSlideHoverPause: true
    });
    jQuery('.iosslider:visible').iosSlider('autoSlidePlay');    

}
jQuery(document).ready(function($) {
    $(window).resize(function(){
        initHomeSlider();
    }).resize();
})          

Hope that helps :)

Tofandel commented 4 years ago

Same issue here, a slider is always initialized but displayed none with media queries (to not appear on mobile)

When you resize the page and the slider gets hidden the browser completely freezes

Tofandel commented 4 years ago

Located the issue and made a PR