basilio / responsiveCarousel

Simple carousel
MIT License
113 stars 64 forks source link

Stop AutoRotate on hover #20

Closed felipeS closed 10 years ago

felipeS commented 10 years ago

Is it possible to stop or pause the autoRotation when i am over any item of the carousel ?

Thanks!

iso100 commented 10 years ago

I'd also like to see this feature implemented.

basilio commented 10 years ago

Hi, It`s not possible by default, but i think you can create it using default triggers, like initCarousel and extend the behavior of obj.rotateTime. Something like this http://pastie.org/8619002

$('#gallery').carousel({ autoRotate : 4000 }); $('#gallery').on( 'initCarousel', function(event, defaults, obj){ $(this).hover( function(){ clearInterval( obj.rotateTime ); }, function(){ obj.rotateTime = window.setInterval( function(){ obj.rotate(); }, defaults.autoRotate ); }); });

Test it and tell me if it works for you :)

Cheers

iso100 commented 10 years ago

Worked perfectly! This is great! Thank you so much!

basilio commented 10 years ago

Great!

browniebroke commented 9 years ago

Hum... For some reason I can't get it to work in my case http://jsfiddle.net/brunoalla/46d0zyxp/1/

Am I missing something obvious? The javascript contains https://raw.githubusercontent.com/basilio/responsiveCarousel/master/responsiveCarousel.js followed by the above snippet, from line 413.