Commit 6a6df4ec authored by dschuyler's avatar dschuyler Committed by Commit bot

[Polymer] update paper-slider for RTL support

This CL applies a pull request submitted to Polymer to add RTL support
for paper-sliders.

BUG=696437
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:closure_compilation

Review-Url: https://codereview.chromium.org/2801193002
Cr-Commit-Position: refs/heads/master@{#462953}
parent aec2cb67
...@@ -53,7 +53,7 @@ ...@@ -53,7 +53,7 @@
"paper-radio-button": "PolymerElements/paper-radio-button#1.3.1", "paper-radio-button": "PolymerElements/paper-radio-button#1.3.1",
"paper-radio-group": "PolymerElements/paper-radio-group#1.2.0", "paper-radio-group": "PolymerElements/paper-radio-group#1.2.0",
"paper-ripple": "PolymerElements/paper-ripple#1.0.9", "paper-ripple": "PolymerElements/paper-ripple#1.0.9",
"paper-slider": "PolymerElements/paper-slider#1.0.13", "paper-slider": "PolymerElements/paper-slider#1.0.15",
"paper-spinner": "PolymerElements/paper-spinner#1.2.0", "paper-spinner": "PolymerElements/paper-spinner#1.2.0",
"paper-styles": "PolymerElements/paper-styles#1.1.4", "paper-styles": "PolymerElements/paper-styles#1.1.4",
"paper-tabs": "PolymerElements/paper-tabs#1.6.2", "paper-tabs": "PolymerElements/paper-tabs#1.6.2",
......
{ {
"name": "paper-slider", "name": "paper-slider",
"version": "1.0.13", "version": "1.0.15",
"description": "A material design-style slider", "description": "A material design-style slider",
"license": "http://polymer.github.io/LICENSE.txt", "license": "http://polymer.github.io/LICENSE.txt",
"authors": "The Polymer Authors", "authors": "The Polymer Authors",
......
...@@ -114,8 +114,10 @@ Polymer({ ...@@ -114,8 +114,10 @@ Polymer({
}, },
keyBindings: { keyBindings: {
'left down pagedown home': '_decrementKey', 'left': '_leftKey',
'right up pageup end': '_incrementKey' 'right': '_rightKey',
'down pagedown home': '_decrementKey',
'up pageup end': '_incrementKey'
}, },
/** /**
...@@ -213,7 +215,9 @@ Polymer({ ...@@ -213,7 +215,9 @@ Polymer({
this._trackStart(event); 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; this._x = this._startx + dx;
var immediateValue = this._calcStep(this._calcKnobPosition(this._x / this._w)); var immediateValue = this._calcStep(this._calcKnobPosition(this._x / this._w));
...@@ -251,6 +255,9 @@ Polymer({ ...@@ -251,6 +255,9 @@ Polymer({
this._w = this.$.sliderBar.offsetWidth; this._w = this.$.sliderBar.offsetWidth;
var rect = this.$.sliderBar.getBoundingClientRect(); var rect = this.$.sliderBar.getBoundingClientRect();
var ratio = (event.detail.x - rect.left) / this._w; var ratio = (event.detail.x - rect.left) / this._w;
if (this._isRTL) {
ratio = 1 - ratio;
}
var prevRatio = this.ratio; var prevRatio = this.ratio;
this._setTransiting(true); this._setTransiting(true);
...@@ -292,6 +299,9 @@ Polymer({ ...@@ -292,6 +299,9 @@ Polymer({
if (steps > maxMarkers) { if (steps > maxMarkers) {
steps = maxMarkers; steps = maxMarkers;
} }
if (steps < 0 || !isFinite(steps)) {
steps = 0;
}
this._setMarkers(new Array(steps)); this._setMarkers(new Array(steps));
}, },
...@@ -315,6 +325,27 @@ Polymer({ ...@@ -315,6 +325,27 @@ Polymer({
}); });
}, },
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);
else
this._decrementKey(event);
},
_rightKey: function(event) {
if (this._isRTL)
this._decrementKey(event);
else
this._incrementKey(event);
},
_incrementKey: function(event) { _incrementKey: function(event) {
if (!this.disabled) { if (!this.disabled) {
if (event.detail.key === 'end') { if (event.detail.key === 'end') {
......
...@@ -88,6 +88,11 @@ Custom property | Description | Default ...@@ -88,6 +88,11 @@ Custom property | Description | Default
:host(:focus) { :host(:focus) {
outline: none; outline: none;
} }
:host-context([dir="rtl"]) #sliderContainer {
-webkit-transform: scaleX(-1);
transform: scaleX(-1);
}
#sliderContainer { #sliderContainer {
position: relative; position: relative;
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
"tag": "2.2.2", "tag": "2.2.2",
"commit": "8cf9e3567c8a30e905e6a2aefb2ebf4120da6859" "commit": "8cf9e3567c8a30e905e6a2aefb2ebf4120da6859"
}, },
"_source": "https://github.com/web-animations/web-animations-js.git", "_source": "git://github.com/web-animations/web-animations-js.git",
"_target": "2.2.2", "_target": "2.2.2",
"_originalSource": "web-animations/web-animations-js" "_originalSource": "web-animations/web-animations-js"
} }
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment