Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to make rtl? #206

Open
ghost opened this issue Aug 10, 2018 · 7 comments
Open

how to make rtl? #206

ghost opened this issue Aug 10, 2018 · 7 comments

Comments

@ghost
Copy link

ghost commented Aug 10, 2018

No description provided.

@ghost ghost changed the title howto make rtl? how to make rtl? Aug 10, 2018
@Arashfiroozabadi
Copy link

Arashfiroozabadi commented Sep 7, 2018

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
Copy link

ghost commented Oct 21, 2018

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

@drinkmaker
Copy link

@Arashfiroozabadi Thank You!
Your solution works perfectly.

@alikazemkhanloo
Copy link

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
Copy link

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

@ShlomoCode
Copy link

ShlomoCode commented Dec 11, 2023

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;
  }

barCSS = { transform: 'translate3d('+toBarPerc(n)+'%,0,0)' };

barCSS = { transform: 'translate('+toBarPerc(n)+'%,0)' };

@mirismaili
Copy link

mirismaili commented Dec 27, 2024

Thank @alikazemkhanloo.

I used this (w/o JS):

[dir='rtl'] body > div#nprogress {
  transform: scaleX(-1);
  position: fixed;
  right: 0;
  top: 0;
  left: 0;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants