malsup / cycle2

2nd gen cycling
899 stars 236 forks source link

Problem with Reinit #605

Open carlosnpz opened 9 years ago

carlosnpz commented 9 years ago

Hey guys! I'm building a carousel using Cycle 2 without the data attributes (initializing via Jquery) and I'd like it to change from horizontal scrolling to vertical when resizing the window. The problem is that after resizing, the carousel stops working.

My code:

   $(window).resize(function(){
    if($(window).width() <= 1024){
        $('#news .slideshow').cycle({
            fx: 'scrollVert',
            timeout: 10000,
            slides: '> ul',
            prev: '#prev2',
            next: '#next2',
            pager: '#pager2',
            pagerTemplate: '<a href="#"><span> {{slideNum}} </span></a>'
        });

        $('#news .slideshow').cycle('reinit');
    }

    else{
        $('#news .slideshow').cycle({
            fx: 'scrollHorz',
            timeout: 10000,
            slides: '> ul',
            prev: '#prev2',
            next: '#next2',
            pager: '#pager2',
            pagerTemplate: '<a href="#"><span> {{slideNum}} </span></a>'
        });

        $('#news .slideshow').cycle('reinit');
    }
   });
GabVenturato commented 6 years ago

I know this is an old issue, but I have the same problem in my code. Reinit destroys my slideshow and it never reinitialize it, even if it in log says that "init" command is launched.

My code is very similar to the carlosnpz, but I have two different sliders in a page, and I put parameters in html. I tried also with something like:

$('.cycle-slideshow').each( function() { $(this).cycle('reinit'); }

but the result is always the same. What I want is make cycle2 to revaluate my images width in order to made a responsive carousel.