Bootstrap 2 seems to work fine handling the slide event (see this question) with the following code:
$('#myCarousel').bind('slide', function (e) {
console.log('slide event!');
});
I cannot, however, get the same things to work in Bootstrap 3 (see this fiddle). Anyone know why?
In browsers where the Page Visibility API is supported, the carousel will avoid sliding when the webpage is not visible to the user (such as when the browser tab is inactive, the browser window is minimized, etc.).
All carousel events are fired at the carousel itself (i.e. at the <div class="carousel"> ). This event fires immediately when the slide instance method is invoked. This event is fired when the carousel has completed its slide transition.
How do I stop bootstrap carousel Auto Slide? Use the [interval]="'0'" input. This will disable the auto-sliding feature.
Bootstrap's carousel class exposes two events for hooking into carousel functionality. Both events have the following additional properties: direction : The direction in which the carousel is sliding (either "left" or "right" ). relatedTarget : The DOM element that is being slid into place as the active item.
Actual event namespace for slide
according to bootstrap3 implementation is slide.bs.carousel as opposed to slide
which was the one acc: to BS2, also use slid.bs.carousel
to track completion of slide (though slid
seems to work.)
So try:
$('#myCarousel').bind('slide.bs.carousel', function (e) {
console.log('slide event!');
});
Demo
On Slide before
h('#HomeSlider').bind('slide.bs.carousel', function (e) {
alert(h('#HomeSlider .item.active').html());
});
On Slide After
h('#HomeSlider').on('slid.bs.carousel', function (e) {
alert(h('#HomeSlider .item.active').html());
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With