Okay
  Public Ticket #3114076
Layerslider gets stuck
Closed

Comments

  • Diana Burr started the conversation

    Layerslider gets stucks. To duplicate the problem go to https://dickiesarena.wpengine.com/ and start clicking the right arrow (or left arrow). Towards the end of the slides it gets stuck. I did add the below script to stop the autoplay when the navigation arrows are clicked. When I remove the lines "slider.api('stop'), it doesn't get stuck but I need this feature. Do you know why its getting stuck?

      // stopping carousel when navigation is clicked
                $('#featured-event-carousel').on('slideshowStateDidChange', function(event, slider) {
                    $('.ls-nav-prev').click(function() {
                        slider.api('stop');
                        slider.api('pauseMedia');
                    });
                    $('.ls-nav-next').click(function() {
                        slider.api('stop');
                        slider.api('pauseMedia');
                    });
                });

  •  68
    John replied

    Hi Diana,

    The slideshowStateDidChange event repeatedly fires, and you're attaching click events again and again that also change the slideshow state, which in turn calls the whole stack again. You're essentially creating a loop that grows larger and larger each time you click on one of the arrow keys.

    I'd suggest running your code in the sliderDidLoad event, which is called only once for each slider. You can also run your code outside of LayerSlider's event handlers by using delegated events, so it doesn't matter when the sliders are loaded.

    Calling pauseMedia shouldn't be necessary since LayerSlider always pauses any active media playback on slide change.

    Best Regards,
    John | Kreatura Dev Team