ganlanyuan / tiny-slider

Vanilla javascript slider for all purposes.
MIT License
5.26k stars 786 forks source link

RTL support #225

Open ali-hellani opened 6 years ago

ali-hellani commented 6 years ago

will the plugin have RTL support in the future ?!

ganlanyuan commented 6 years ago

Yes.

lbineau commented 6 years ago

Any release planned?

asennoussi commented 6 years ago

Any news about this guys? If not, can you recommend a library that supports rtl?

ganlanyuan commented 6 years ago

Supper busy recently. Won't be able to add this feature in 1 month.

santamaria7 commented 5 years ago

Any news about this feature?

ganlanyuan commented 5 years ago

Just finished center, will start work on this. But it will take some time due to the overall complexity.

andrepereiradasilva commented 5 years ago

+1 for rtl support

QusaiNaim commented 5 years ago

Any news about this feature?

wouterkroes commented 5 years ago

Any news about this feature, any idea when it will added?

joeyrubio commented 5 years ago

RTL support would be amazing. Any updates @ganlanyuan ? Thanks!!!

piotrku commented 5 years ago

It probably needs some more testing but looks like my quick fix added RTL support for horizontal carousel slider setup, just check: https://github.com/piotrku/tiny-slider/commit/a7b88d66e3513ebcd01df4bd062791271b1b3d24

wouterkroes commented 5 years ago

Any updates?

therayess commented 5 years ago

Hi, any updates on this please? RTL support would be perfect, thanks

mrk9776 commented 5 years ago

Any updates?

yelsayed commented 5 years ago

Until a PR is approved or is developed. A quick fix is to make a wrapper to the dom object defined in your container, and make that wrapper have direction: ltr style. It doesn't look so bad on Arabic websites and it's a good solution if you want to continue using this lib.

sneetsher commented 5 years ago

@ganlanyuan Hi, I'm not so advanced dev. I would like to try adding RTL support, if you don't mind and if no one is already doing it?

I'm setting up its dev env as documented in Contribute file. Please, let me if there any other important point I should be aware of or any advice.

I'm going to use this convention: dir="rtl" in HTML as switch, same CSS files for both LTR/RTL.

As documented in Drupal docs - CSS formatting guidelines.

ali-joghataei commented 4 years ago

Any news about this ? @ganlanyuan

alivazirinia commented 4 years ago

@ganlanyuan Hi, any plan for adding RTL support?

samikeijonen commented 4 years ago

It probably needs some more testing but looks like my quick fix added RTL support for horizontal carousel slider setup, just check: piotrku@a7b88d6

@piotrku Thanks for this! In my test this worked like a charm.

Would be nice to be implemented in the original repo :)

sa8ab commented 4 years ago

using

.tns-carousel {
  display: flex;
  flex-direction: row-reverse;
}

reverses the items but still it starts from left

mahdinai commented 3 years ago

rtl repo: npm i tiny-slider-rtl --save

danstramer commented 2 years ago

is there an update? adding RTL support similar to owl slider: https://owlcarousel2.github.io/OwlCarousel2/demos/rtl.html

Thanks! Dan

sneetsher commented 2 years ago

@danstramer check PR from jmfarina https://github.com/ganlanyuan/tiny-slider/pull/658

youth10313 commented 2 years ago

Until a PR is approved or is developed. A quick fix is to make a wrapper to the dom object defined in your container, and make that wrapper have direction: ltr style. It doesn't look so bad on Arabic websites and it's a good solution if you want to continue using this lib.

many thanks

hamajamaldev commented 1 year ago

from tiny-slider.js inside this if (hasAutoplay) {} change

var autoplayDirection = options.autoplayDirection === 'forward' ? 1 : -1,

to var autoplayDirection = options.autoplayDirection === 'backward' ? 1 : -1,

to change direction i used this and worked

mostafa-norouzi commented 1 year ago

.tns-carousel { display: flex; flex-direction: row-reverse; }

It also makes problem if Lazy load be on

mostafa-norouzi commented 1 year ago

As tiny-slider seems dead totally, I switched to the Splide. It supports RTL very well

ivankomartin commented 5 months ago

This is how I handled RTL; it works perfectly. I played with the direction: rtl/ltr, reversed the slider row, created a function that moves the slider to the end, and then displays the hidden slider. !! The code is not complete; I only extracted what I changed.


html:dir(rtl) {
  .tns-item {
    direction: rtl;
  }
  .slider-wrapper {
    direction: ltr;
  }
  .slider {
    flex-direction: row-reverse;
  }
  .hidden-carousel {
    visibility: hidden;
  }
}
<div class="hidden-carousel">
  {{#with shop.carousel}}
  <div>
    <div class="c-carousel">
      <div class="slider-wrapper">
        <div id="slider" class="slider">
          {{#each list }}
          <div class="h-pt-8">card-data</div>
          {{/each}}
        </div>
      </div>
    </div>
  </div>
  {{/with}}
</div>
<script>
  document.addEventListener("DOMContentLoaded", function() {
    document
      .querySelectorAll("[data-carousel-id]")
      .forEach(function(carouselElement) {
        var isRTL = document.documentElement.getAttribute("dir") === "rtl";
        !isRTL && carouselElement.classList.remove("hidden-carousel");

        function goToLastSlide() {
          var interval = setInterval(function() {
            var info = slider.getInfo();
            if (info.index + info.items < info.slideCount) {
              nextArrow.click();
            } else {
              clearInterval(interval);
              setTimeout(function() {
                carouselElement.classList.remove("hidden-carousel");
              }, 200);
            }
          }, 0);
        }

        isRTL && goToLastSlide();
      });
  });
</script>