How can you tell whether the twitter bootstrap carousel is going fwd or back? I want to be able to do something like:
$('#myCarouse').on('slide', function(e) {
if (fwd?) {do something}
});
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The only special info the Carousel plugin appends to the slide event object is a
relatedTargetproperty which contains the element that is going to be switched to. That can be used to manually calculate where you are about to move in the carousel.Something along the lines of:
That
diff === 0is to handle the strange behavior I saw when on the last slide and moving to the first one. For some reason,activePosandnextPoscome out equal. I can’t make sense of it; it just is.Here’s a demo:
JSFiddle