Skip to content

Commit

Permalink
fix(range): improved rtl support (#17479)
Browse files Browse the repository at this point in the history
* fix(Range): rtl support

* fix(Range): knob position in rtl
  • Loading branch information
KillerCodeMonkey authored and liamdebeasi committed Feb 13, 2019
1 parent 15acb4b commit f832de5
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions core/src/components/range/range.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -384,25 +384,27 @@ export class Range implements ComponentInterface {
const { min, max, neutralPoint, ratioLower, ratioUpper } = this;
const neutralPointRatio = valueToRatio(neutralPoint, min, max);

const isRTL = document.dir === 'rtl';
const start = isRTL ? 'right' : 'left';
const end = isRTL ? 'left' : 'right';
const style: any = {};

// dual knob handling
let left = `${ratioLower * 100}%`;
let right = `${100 - ratioUpper * 100}%`;
style[start] = `${ratioLower * 100}%`;
style[end] = `${100 - ratioUpper * 100}%`;

// single knob handling
if (!this.dualKnobs) {
if (this.ratioA < neutralPointRatio) {
right = `${neutralPointRatio * 100}%`;
left = `${this.ratioA * 100}%`;
style[end] = `${neutralPointRatio * 100}%`;
style[start] = `${this.ratioA * 100}%`;
} else {
right = `${100 - this.ratioA * 100}%`;
left = `${neutralPointRatio * 100}%`;
style[end] = `${100 - this.ratioA * 100}%`;
style[start] = `${neutralPointRatio * 100}%`;
}
}

return {
left,
right
};
return style;
}

protected isTickActive(stepRatio: number) {
Expand Down Expand Up @@ -537,7 +539,6 @@ function renderKnob({ knob, value, ratio, min, max, neutralPoint, disabled, pres

const knobStyle = () => {
const style: any = {};

style[start] = `${ratio * 100}%`;

return style;
Expand Down

0 comments on commit f832de5

Please sign in to comment.