Skip to content
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

Can't stop carousel in autoplay mode after 'to.owl.carousel' trigger #144

Closed
sferrara opened this issue Jun 11, 2014 · 21 comments
Closed

Can't stop carousel in autoplay mode after 'to.owl.carousel' trigger #144

sferrara opened this issue Jun 11, 2014 · 21 comments
Labels
Milestone

Comments

@sferrara
Copy link

Hello,
I've this 2 rows in my code:
owl.trigger('stop.owl.autoplay');
owl.trigger('to.owl.carousel',[index],[0]);

but the carousel doesn't stop. If I remove the first row the stop works.

Can you help me?

Best Regards
Stefano

@witrin
Copy link
Contributor

witrin commented Jun 16, 2014

@sferrara Could you provide a link to an example?

@nford
Copy link

nford commented Jun 16, 2014

I'll just jump in here. I couldn't get the event above, or autoplay.stop.owl to work. Added to codepen. http://codepen.io/nford/pen/Jefcr

@witrin
Copy link
Contributor

witrin commented Jun 16, 2014

@nford Thanks!

@witrin witrin added the bug label Jun 16, 2014
@witrin witrin added this to the 2.0.0-beta.3 milestone Jun 22, 2014
@witrin
Copy link
Contributor

witrin commented Jul 27, 2014

@witrin witrin closed this as completed in c9fbddf Jul 29, 2014
@mufaddalmw
Copy link

@witrin Demo provided by you above doesn't seem to be working. Can you update?

@lmartins
Copy link

lmartins commented Feb 3, 2015

Have anyone found out a solution for this, can't make autoplay stop either.

@alteredstudio
Copy link

I tried this. Should work according to the Owl 2.0 docs. It never stops on hover, or autoplay.stop.owl
Any updates on bug fixes, or work arounds? Thanks

$('.owl-carousel').owlCarousel({
loop:true,
nav:true,
items:1,
margin:0,
autoplay:true,
autoplayHoverPause:true,
});

$('.owl-item, .owl-prev, .owl-next, .owl-dot span').on('click',function(){
$('.owl-carousel').trigger('autoplay.stop.owl')
})

@lmartins
Copy link

lmartins commented Feb 6, 2015

Now that OwlCarousel changed hand, maybe we will see a fix soon. Let's hope.

@ghost
Copy link

ghost commented Mar 31, 2015

Is there any more news on this? I've come across this issue now and would love for it to stop on request. Has any progress been made?

@ghost
Copy link

ghost commented Mar 31, 2015

I've taken a look at the code and it seems you're just missing one line of code. The autoplay handlers has this for the stop event:

...
'stop.owl.autoplay': $.proxy(function() {
    this.stop();
}, this),
...

Looking at the stop() function, it is only set to this:

Autoplay.prototype.stop = function() {
    window.clearInterval(this.interval);
};

This only clears the interval but doesn't stop the autoplay. Adding in a line to set the option fixes this:

Autoplay.prototype.stop = function() {
    window.clearInterval(this.interval);
    this.core.settings.autoplay = false;
};

Note this may need a similar fix if you want to start autoplay as well but I haven't tested that. Hope this helps with the fix and helps anyone who needs this functionality.

@nord1dea
Copy link

nord1dea commented Apr 9, 2015

Thanks to @TcPhilBushnell. It works for me!

@morettolss
Copy link

Confirm @TcPhilBushnell works also for me.

@Balloonatic
Copy link

@TcPhilBushnell your trick works for me, but I also had to use 'stop.autoplay.owl' instead of 'stop.owl.autoplay'.

@ghost
Copy link

ghost commented Apr 24, 2015

The code will look for stop.owl.autoplay so that is the event to use - the documentation is/was incorrect (saying stop.autoplay.owl) but you could make the code match the [old] documentation if you desired.

Generally it's ill advised to edit vendor code unless there's no way of fixing an issue with additional code.

@piotrkrzempek
Copy link

Looked for problem and found that owl.trigger('stop.owl.autoplay'); works, but have to be triggered few times (because I'm not sure when this event will be accepted). I've created simple interval, that triggers owl.trigger('stop.owl.autoplay'); every 100ms, and clears itself after few seconds. Working fine!

@rokinroj
Copy link

rokinroj commented Mar 1, 2016

Thanks @TcPhilBushnell! That fix was huge! Thanks again

@ch1cote
Copy link

ch1cote commented Jul 29, 2016

Looks like on the stop() function is checking to see if the animation is in progress. If it is then it doesn't clear the timeout.

Autoplay.prototype.stop = function() {
        if (!this._core.is('rotating')) {
            return;
        }
        window.clearTimeout(this._timeout);
        this._core.leave('rotating');
    };

For my purposes I just commented out the if statement and it did the trick. Not sure what other implications that might have on more complex uses of the plugin.

@stairie
Copy link

stairie commented Sep 30, 2016

Holy crap @TcPhilBushnell, you just stopped me from throwing my entire desk out my window! Thank you so much for that fix!

@krolovolk
Copy link

Thanks a lot! @TcPhilBushnell it's cool to be you)

@sadiqueo
Copy link

thanks @TcPhilBushnell .

For start/play autoplay again after stop, I have changed this code

'play.owl.autoplay': $.proxy(function(e, t, s) {
this.play(t, s);
}, this),
to

'play.owl.autoplay': $.proxy(function(e, t, s) {
this.core.settings.autoplay = true;
this.autoplay();
this.play(t, s);
}, this),

this is working for me . hope this will help anyone need this play again funtionality

@swd99999999
Copy link

This fix for autoplay problems.

` Autoplay.prototype.stop = function() {
if (!this._core.is('rotating')) {
return;
}

	window.clearTimeout(this._timeout);
	this._core.settings.autoplay = false; //Add this line.		
	this._core.leave('rotating');
};`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

17 participants