Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Unified Diff: third_party/polymer/v1_0/components-chromium/paper-slider/paper-slider-extracted.js

Issue 2800953002: [MD settings] support RTL in paper-slider (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/polymer/v1_0/components-chromium/paper-slider/paper-slider.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/polymer/v1_0/components-chromium/paper-slider/paper-slider-extracted.js
diff --git a/third_party/polymer/v1_0/components-chromium/paper-slider/paper-slider-extracted.js b/third_party/polymer/v1_0/components-chromium/paper-slider/paper-slider-extracted.js
index b555b0a43bafe40f50066bbb8433abcbbdea2b7f..4c5f461075cd3a8aee96adf1816bb8a4656b03fb 100644
--- a/third_party/polymer/v1_0/components-chromium/paper-slider/paper-slider-extracted.js
+++ b/third_party/polymer/v1_0/components-chromium/paper-slider/paper-slider-extracted.js
@@ -114,8 +114,8 @@ Polymer({
},
keyBindings: {
- 'left down pagedown home': '_decrementKey',
- 'right up pageup end': '_incrementKey'
+ 'left down pagedown home': '_leftKey',
+ 'right up pageup end': '_rightKey'
},
/**
@@ -213,7 +213,9 @@ Polymer({
this._trackStart(event);
}
- var dx = Math.min(this._maxx, Math.max(this._minx, event.detail.dx));
+ var direction = this._isRTL ? -1 : 1;
+ var dx = Math.min(
+ this._maxx, Math.max(this._minx, event.detail.dx * direction));
this._x = this._startx + dx;
var immediateValue = this._calcStep(this._calcKnobPosition(this._x / this._w));
@@ -315,9 +317,30 @@ Polymer({
});
},
- _incrementKey: function(event) {
+ get _isRTL() {
+ if (this.__isRTL === undefined) {
+ this.__isRTL = window.getComputedStyle(this)['direction'] === 'rtl';
+ }
+ return this.__isRTL;
+ },
+
+ _leftKey: function(event) {
+ if (this._isRTL)
+ this._incrementKey(event, 'home');
+ else
+ this._decrementKey(event, 'home');
+ },
+
+ _rightKey: function(event) {
+ if (this._isRTL)
+ this._decrementKey(event, 'end');
+ else
+ this._incrementKey(event, 'end');
+ },
+
+ _incrementKey: function(event, allTheWayKey) {
if (!this.disabled) {
- if (event.detail.key === 'end') {
+ if (event.detail.key === allTheWayKey) {
this.value = this.max;
} else {
this.increment();
@@ -327,9 +350,9 @@ Polymer({
}
},
- _decrementKey: function(event) {
+ _decrementKey: function(event, allTheWayKey) {
if (!this.disabled) {
- if (event.detail.key === 'home') {
+ if (event.detail.key === allTheWayKey) {
this.value = this.min;
} else {
this.decrement();
« no previous file with comments | « third_party/polymer/v1_0/components-chromium/paper-slider/paper-slider.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698