Skip to content

Commit e136ac3

Browse files
committed
feat(QSlider/QRange): RTL support
1 parent 96c5354 commit e136ac3

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

src/components/range/QRange.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ export default {
134134
}
135135

136136
let
137-
percentage = getPercentage(event, this.dragging),
137+
percentage = getPercentage(event, this.dragging, this.$q.i18n.rtl),
138138
type
139139

140140
if (percentage < this.currentMinPercentage + sensitivity) {
@@ -170,7 +170,7 @@ export default {
170170
},
171171
__update (event) {
172172
let
173-
percentage = getPercentage(event, this.dragging),
173+
percentage = getPercentage(event, this.dragging, this.$q.i18n.rtl),
174174
model = getModel(percentage, this.min, this.max, this.step, this.computedDecimals),
175175
pos
176176

@@ -269,7 +269,7 @@ export default {
269269
ref: `handle${upper}`,
270270
staticClass: `q-slider-handle q-slider-handle-${lower}`,
271271
style: {
272-
left: `${percentage * 100}%`,
272+
[this.$q.i18n.rtl ? 'right' : 'left']: `${percentage * 100}%`,
273273
borderRadius: this.square ? '0' : '50%'
274274
},
275275
'class': [
@@ -298,7 +298,7 @@ export default {
298298
h('div', {
299299
staticClass: 'q-slider-track active-track',
300300
style: {
301-
left: `${this.percentageMin * 100}%`,
301+
[this.$q.i18n.rtl ? 'right' : 'left']: `${this.percentageMin * 100}%`,
302302
width: this.activeTrackWidth
303303
},
304304
'class': {

src/components/slider/QSlider.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export default {
7979
},
8080
__update (event) {
8181
let
82-
percentage = getPercentage(event, this.dragging),
82+
percentage = getPercentage(event, this.dragging, this.$q.i18n.rtl),
8383
model = getModel(percentage, this.min, this.max, this.step, this.computedDecimals)
8484

8585
this.currentPercentage = percentage
@@ -117,7 +117,7 @@ export default {
117117
h('div', {
118118
staticClass: 'q-slider-handle',
119119
style: {
120-
left: this.percentage,
120+
[this.$q.i18n.rtl ? 'right' : 'left']: this.percentage,
121121
borderRadius: this.square ? '0' : '50%'
122122
},
123123
'class': {

src/components/slider/slider-utils.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ import { between } from '../../utils/format'
22
import { position } from '../../utils/event'
33
import TouchPan from '../../directives/touch-pan'
44

5-
export function getPercentage (event, dragging) {
6-
return between((position(event).left - dragging.left) / dragging.width, 0, 1)
5+
export function getPercentage (event, dragging, rtl) {
6+
const val = between((position(event).left - dragging.left) / dragging.width, 0, 1)
7+
return rtl ? 1.0 - val : val
78
}
89

910
export function notDivides (res, decimals) {

0 commit comments

Comments
 (0)