rstacruz / nprogress

For slim progress bars like on YouTube, Medium, etc
http://ricostacruz.com/nprogress
MIT License
25.98k stars 1.81k forks source link

how to make rtl? #206

Open ghost opened 5 years ago

Arashfiroozabadi commented 5 years ago

its work for me. css #nprogress .bar { left: auto !important; right: 0; } and in node_modules\nprogress\nprogress.js change perc = fromStart ? '-100' : toBarPerc(NProgress.status || 0), to perc = fromStart ? '100' : toBarPerc(NProgress.status || 0), and function toBarPerc(n) { return (-1 + n) * 100; } to function toBarPerc(n) { return 100 - (n * 100); }

ghost commented 5 years ago

@Erkajp the code that @Arashfiroozabadi just posted works very well!

drinkmaker commented 4 years ago

@Arashfiroozabadi Thank You! Your solution works perfectly.

alikazemkhanloo commented 1 year ago

A workaround could be:

 "#nprogress": {
            transform: isRTL() ? "scaleX(-1)" : "unset",
            position: "fixed",
            top: 0,
            left: 0,
            right: 0,
            zIndex: 9999999,
        },

You can use JS to detect RTL if you're using JSS or use css selectors. No need to change anything in node_modules.

itsramiel commented 9 months ago

use https://www.npmjs.com/package/nprogress-support-rtl

ShlomoCode commented 7 months ago

its work for me. css #nprogress .bar { left: auto !important; right: 0; } and in node_modules\nprogress\nprogress.js change perc = fromStart ? '-100' : toBarPerc(NProgress.status || 0), to perc = fromStart ? '100' : toBarPerc(NProgress.status || 0), and function toBarPerc(n) { return (-1 + n) * 100; } to function toBarPerc(n) { return 100 - (n * 100); }

It works, but here's a shorter way: add rotateY(180deg) to transform (in barPositionCSS function)

  function barPositionCSS(n, speed, ease) {
    var barCSS;

    if (Settings.positionUsing === 'translate3d') {
      barCSS = { transform: 'rotateY(180deg) translate3d(' + toBarPerc(n) + '%,0,0)' };
    } else if (Settings.positionUsing === 'translate') {
      barCSS = { transform: 'rotateY(180deg) translate(' + toBarPerc(n) + '%,0)' };
    } else {
      barCSS = { 'margin-left': toBarPerc(n)+'%' };
    }

    barCSS.transition = 'all '+speed+'ms '+ease;

    return barCSS;
  }

https://github.com/rstacruz/nprogress/blob/e1a8b7fb6e059085df5f83c45d3c2308a147ca18/nprogress.js#L349 https://github.com/rstacruz/nprogress/blob/e1a8b7fb6e059085df5f83c45d3c2308a147ca18/nprogress.js#L351