Search code examples
javascripttwitter-bootstrapcarousel

Bootstrap JS 3 carousel rotate Left To Right


I'm using bootstrap 3 carousel to rotate images on the banner. Is there any attribute i can add to my code to force the slides to be flipped RTL or LTR? if not how can it possibly be done? here's my code:

    $('.carousel').carousel({
         interval: 3000,
         pause: "hover",
    });

Solution

  • There's no option to change the direction of a Bootstrap Carousel.

    You'll have to do it yourself. You can override the function of Bootstrap by running this code before yours.

    $.fn.carousel.Constructor.prototype.next = function () {
      if (this.sliding) return;
      return this.slide('prev');
    };
    
    $.fn.carousel.Constructor.prototype.prev = function () {
      if (this.sliding) return;
      return this.slide('next');
    };
    

    But be carefull, it will change the direction for all Carousel on page and the controls will be reversed.