-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stop autoplay while hovering #191
Comments
Right, and will not be. You can call .stopAutoPlay() and .startAutoPlay() within jQuery's .hover handlers http:https://api.jquery.com/hover/ |
Seems .stopAutoplay() and .startAutoplay don't work on the latest version. Tested on default demo by adding $('.swiper-container').hover(mySwiper.stopAutoplay(),mySwiper.startAutoplay()). |
stopAutoplay not working for me either. |
@mairead give me a link to your project so i can take a look |
Hey @nolimits4web @ptz-nerf, @mairead |
Fixes autoplay bug mentioned in #191 comments
$(".swiper-container").hover(function(){ |
What if you have more than one instance? How would you reuse the stop and play functions? $(".swiper-container").hover(function(){ |
var mySwiper = $('.swiper-container')[0].swiper;` But during initialization your already have instance: var mySwiper = new Swiper('#target');
$("#target").hover(function(){
mySwiper.stopAutoplay();
}, function(){
mySwiper.startAutoplay();
}); |
Your approach suggests that if I have 3 instances (e.g. swiper1, swiper2, swiper3) and I want to stop the autoplay on hover, then I should go and do this block for each one of them like so:
However that's not really DRY is it? Instead, the following solution, that I found, works way better:
So this is how you get the instance without referencing to the variables |
|
The code @monty-georgiev posted should be included as an option in swiper. I shouldn't have to hack the library with jQuery in order to get some desired functionality. :) |
I'm getting |
NVM, just found the solution in the api documentation:
|
no jQuery solution
|
There is no option for that
The text was updated successfully, but these errors were encountered: