Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8532337
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:41:34+00:00 2026-06-11T09:41:34+00:00

How can I determine whether the carousel is sliding left or right? I’ve looked

  • 0

How can I determine whether the carousel is sliding left or right? I’ve looked at the documentation for the events slid and slide, but neither provide any relevant information on the direction of the slide.

I’ve also examined the event object that gets passed to the event handler for the slid event, but I can’t seem to find any useful clues there either.

Any help would be appreciated!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T09:41:35+00:00Added an answer on June 11, 2026 at 9:41 am

    So as far as I can see twitter bootstrap doesn’t expose what direction the carousel is moving via the event object. However, it DOES add a “right” or “left” class to elements involved in the slide.

    So basically i see 2 options. Expose the direction in the event object or look for the right or left class on the elements.

    Option 1:

    You will have to modify the bootstrap carousel code. In the carousel, slide function change:

    e = $.Event('slide')
    

    to

    e = $.Event('slide', {direction: direction})
    

    (around line 337-340 in the normal version of bootstrap.js)

    and then you can get the direction with something like this:

    var $carousel = $('.carousel');
    $carousel.carousel();
    
    $carousel.bind('slide', function(e) {
      console.log("e.direction = " + e.direction);
    });
    

    OR Option2:

    Wait some time for the css “left” or “right” class to be added to the element and then check if that class is present.

    var $carousel = $('.carousel');
    $carousel.carousel();
    
    $carousel.bind('slide', function(e) {
    
      setTimeout( function(){
        var left = $carousel.find('.item.active.left');
        var right = $carousel.find('.item.active.right');
        if(left.length > 0) {
          console.log('left');
        }
        else if(right.length > 0) {
          console.log('right');
        }
      }, 500);
    });
    

    Need the timeout because there is a race condition between when the event is triggered and when the left right classes are set. Obviously this is a hackyer solution, but you don’t have to modify the bootstrap code. There are probably other options too, but i feel option 1 is the best.

    Edit: In the latest version of bootstrap css (2.1.1) The line change for option 1 would be:

    (line 340)
    from:

    , e = $.Event('slide', {
      relatedTarget: $next[0]
    })
    

    to:

    , e = $.Event('slide', {
      relatedTarget: $next[0],
      direction: direction
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There are two polygons given. how can one determine whether one polygon is inside,
How can I determine programmatically whether my machine is an x86, x64 or an
How can I use jQuery to determine whether an element has a certain style
Is there a sensible way to determine whether the current user can access an
Given an Youtube video id how can I determine from JavaScript whether the video
How can I determine type of mysql database : whether it is InnoDB or
I can determine the current number of connections by db.serverStatus().connections but all that gives
How can I determine whether the first character of a string is a letter,
Unfortunately my hMailServer can't send emails to Hotmail. How can I determine whether a
How can I determine whether a given node is present in my input xml?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.