After pausing, unslider autoplays when swiping. #419

Open
F-Tahir opened this Issue Jul 18, 2016 · 0 comments

Projects

None yet

1 participant

@F-Tahir
F-Tahir commented Jul 18, 2016 edited

Hi.

I've enabled swipe on Unslider with the following lines:

    <script src="http://stephband.info/jquery.event.move/js/jquery.event.move.js"></script>
    <script src="http://stephband.info/jquery.event.swipe/js/jquery.event.swipe.js"></script>

I've written some jquery such that when I hit a pause button, unslider.stop() method is called and the slides stop autoplaying. However when swiping while paused, the autoplay starts up again. is there anyway I can fix this behaviour? My code is as follows:

        jQuery(document).ready(function($) {
            $('#slider-content').unslider({
                infinite: true,
                autoplay: true,
                arrows: false,
                delay: 4500,
                speed: 500,
                nav: true,
            });


            /* Function to start/stop image slider */
            $('#slider-content i').click(function() {
                if ( $('#slider-content>i').hasClass("fa-pause-circle") ) {
                    $('#slider-content').data('unslider').stop();
                    $('#slider-content>i').toggleClass('fa-pause-circle fa-play-circle');
                } else {
                    $('#slider-content').data('unslider').start();
                    $('#slider-content>i').toggleClass('fa-pause-circle fa-play-circle');
                }
            });

        });

Any help is appreciated. Also on a sidenote, is there any way to stop the slides re-initializing (i.e. not having to wait the full delay) when paused and played again?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment