Monaca Onsen UI Discord Chat Github Repo

RTL right to left Carousel



  • Hii
    I am trying to change the direction of the swiping for carousel and still having issues.
    I tried to change the css into rtl direction but it seems this not enough. there is another change to make on the code js file.
    Can you direct me through this?
    The carousel should start from the right, and swiping it left will make it swipe left.

    thanks


  • administrators

    The carousel already swipes left and right if you have swipeable set.

    All you need to is set the initial starting item to the last one by setting the initial-index to the number of items you have minus 1. So if you have 3 items in your carousel set it to 2:

    <ons-carousel initial-index="2" swipeable></ons-carousel>
    


  • @emccorson said in RTL right to left Carousel:

    initial-index=“2”

    Yes, this make the slider swipe from right to left.
    but the first image is placed on the left and the other sliders are hidden behind it. I couldn’t fix that with css.


  • administrators

    That’s probably more bother than it’s worth to try and fix. I would suggest just adding your items in reverse order e.g.

    <ons-carousel>
      <ons-carousel-item>third</ons-carousel-item>
      <ons-carousel-item>second</ons-carousel-item>
      <ons-carousel-item>first</ons-carousel-item>
    </ons-carousel>