• Resolved Gerald

    (@gerital)


    I want to stop autoplay on my Swiper slider on mouseover and start it again on mouseout. What I normally do is to catch the on init event to then apply the methods:

    on: {
    	init: function() {
    		jQuery(swiperClass).each(function(elem, target){
    			var swp = target.swiper;
    			jQuery(this).hover(function() {
    				swp.autoplay.stop();
    			}, function() {
    				swp.autoplay.start();
    			});
    		});
    	}
    },

    Any possibility to catch the Swiper on init event?

    • This topic was modified 3 years, 8 months ago by Gerald.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author digitalapps

    (@digitalapps)

    You can try and use the second method ‘after initialization’

    https://swiperjs.com/swiper-api#events

    all swipers are stored in the array

    window.wpSwiper

    Let me know how you go

    Thread Starter Gerald

    (@gerital)

    Thanks, that worked out great, at least if I only have one swiper on the page:

    jQuery(".swiper-container").hover(function() {
        window.wpSwiper[0].autoplay.stop();
    }, function() {
        window.wpSwiper[0].autoplay.start();
    });

    I’m not sure what I would have to do so if there are multiple swipers…

    Plugin Author digitalapps

    (@digitalapps)

    I think you should be able to set an id to each swiper or a class, then loop through array, and do stuff to the swiper

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Swiper on init event’ is closed to new replies.