sdvnksv
sdvnksv

Reputation: 9668

How do I know the direction of the Bootstrap carousel slide? Any event?

I need to bind an event upon bootstrap carousel slide to right only. I've got this code:

$('#carousel-showcase').bind('slid', function () {
    $("#wrap").animate({
        backgroundPositionX: '+=50%'
    },0);
});

But it works doesn't matter the direction. Any help?

Upvotes: 2

Views: 1966

Answers (1)

ringstaff
ringstaff

Reputation: 2325

If you are using Bootstrap 3, you can get the direction from the slide event:

$('#carousel-showcase').bind('slide.bs.carousel', function (event) {
    console.log(event.direction);
});

Keep in mind that this is only for the slide event, not slid.

Upvotes: 6

Related Questions