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

Unified Diff: third_party/polymer/v1_0/components/paper-slider/paper-slider.html

Issue 1187823002: Update Polymer components and re-run reproduce.sh (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 6 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
Index: third_party/polymer/v1_0/components/paper-slider/paper-slider.html
diff --git a/third_party/polymer/v1_0/components/paper-slider/paper-slider.html b/third_party/polymer/v1_0/components/paper-slider/paper-slider.html
index 135dba8bf87e7b0e3feebfaa730a1cf03520ab8b..c51236fcf5cb291f06616362ef09ef3493af8bdd 100644
--- a/third_party/polymer/v1_0/components/paper-slider/paper-slider.html
+++ b/third_party/polymer/v1_0/components/paper-slider/paper-slider.html
@@ -8,11 +8,14 @@ Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS
-->
+<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../paper-styles/paper-styles.html">
-<link rel="import" href="../iron-flex-layout/iron-flex-layout.html">
-<link rel="import" href="../iron-behaviors/iron-control-state.html">
<link rel="import" href="../paper-progress/paper-progress.html">
<link rel="import" href="../paper-input/paper-input.html">
+<link rel="import" href="../paper-behaviors/paper-inky-focus-behavior.html">
+<link rel="import" href="../paper-ripple/paper-ripple.html">
+<link rel="import" href="../iron-a11y-keys-behavior/iron-a11y-keys-behavior.html">
+<link rel="import" href="../iron-form-element-behavior/iron-form-element-behavior.html">
<!--
`paper-slider` allows user to select a value from a range of values by
@@ -81,15 +84,26 @@ To change the slider disabled secondary progress bar color:
-->
<dom-module id="paper-slider">
+
<link rel="import" type="css" href="paper-slider.css">
+
<template>
- <template is="dom-if" if="{{!disabled}}">
- </template>
+ <div id="sliderContainer"
+ class$="[[_getClassNames(disabled, pin, snaps, immediateValue, min, expand, dragging, transiting, editable)]]">
- <div id="sliderContainer" class$="[[_getClassNames(disabled, pin, snaps, immediateValue, min, expand, dragging, transiting, editable)]]">
<div class="bar-container">
- <paper-progress id="sliderBar" aria-hidden="true" min="[[min]]" max="[[max]]" value="[[immediateValue]]" secondary-progress="[[secondaryProgress]]"
- on-down="_bardown" on-up="_resetKnob" on-track="_onTrack"></paper-progress>
+ <paper-progress
+ id="sliderBar"
+ aria-hidden="true"
+ min="[[min]]"
+ max="[[max]]"
+ step="[[step]]"
+ value="[[immediateValue]]"
+ secondary-progress="[[secondaryProgress]]"
+ on-down="_bardown"
+ on-up="_resetKnob"
+ on-track="_onTrack">
+ </paper-progress>
</div>
<template is="dom-if" if="[[snaps]]">
@@ -100,20 +114,27 @@ To change the slider disabled secondary progress bar color:
</div>
</template>
- <div id="sliderKnob" on-down="_knobdown" on-up="_resetKnob"
+ <div id="sliderKnob"
+ class="center-justified center horizontal layout"
+ on-down="_knobdown"
+ on-up="_resetKnob"
on-track="_onTrack"
- on-transitionend="_knobTransitionEnd"
- center-justified center horizontal layout>
-
- <div id="sliderKnobInner" value$="[[immediateValue]]"></div>
+ on-transitionend="_knobTransitionEnd">
+ <paper-ripple id="ink" class="circle" center></paper-ripple>
+ <div id="sliderKnobInner" value$="[[immediateValue]]"></div>
</div>
</div>
<template is="dom-if" if="[[editable]]">
- <paper-input id="input" class="slider-input" disabled$="[[disabled]]" on-change="_inputChange"></paper-input>
+ <paper-input
+ id="input"
+ class="slider-input"
+ disabled$="[[disabled]]"
+ on-change="_inputChange">
+ </paper-input>
</template>
-
</template>
+
</dom-module>
<script>
@@ -143,11 +164,12 @@ To change the slider disabled secondary progress bar color:
behaviors: [
Polymer.IronRangeBehavior,
- Polymer.IronControlState
+ Polymer.IronA11yKeysBehavior,
+ Polymer.IronFormElementBehavior,
+ Polymer.PaperInkyFocusBehavior
],
properties: {
-
/**
* If true, the slider thumb snaps to tick marks evenly spaced based
* on the `step` property value.
@@ -160,7 +182,7 @@ To change the slider disabled secondary progress bar color:
/**
* If true, a pin with numeric value label is shown when the slider thumb
- * is pressed. Use for settings for which users need to know the exact
+ * is pressed. Use for settings for which users need to know the exact
* value of the setting.
*/
pin: {
@@ -232,6 +254,7 @@ To change the slider disabled secondary progress bar color:
},
markers: {
+ type: Array,
readOnly: true,
value: []
},
@@ -245,8 +268,19 @@ To change the slider disabled secondary progress bar color:
'_immediateValueChanged(immediateValue)'
],
+ hostAttributes: {
+ role: 'slider',
+ tabindex: 0
+ },
+
+ keyBindings: {
+ 'left down pagedown home': '_decrementKey',
+ 'right up pageup end': '_incrementKey'
+ },
+
ready: function() {
// issue polymer/polymer#1305
+
this.async(function() {
this._updateKnob(this.value);
this._updateInputValue();
@@ -287,11 +321,12 @@ To change the slider disabled secondary progress bar color:
},
_immediateValueChanged: function() {
- if (!this.dragging) {
+ if (this.dragging) {
+ this.fire('immediate-value-change');
+ } else {
this.value = this.immediateValue;
}
this._updateInputValue();
- this.fire('immediate-value-change');
},
_secondaryProgressChanged: function() {
@@ -300,23 +335,26 @@ To change the slider disabled secondary progress bar color:
_updateInputValue: function() {
if (this.editable) {
- this.$$('#input').value = this.immediateValue;
+ this.$$('#input').value = this.immediateValue.toString();
}
},
_expandKnob: function() {
+ this.$.ink.holdDown = false;
this._setExpand(true);
},
_resetKnob: function() {
- this._expandJob && this._expandJob.stop();
+ this.cancelDebouncer('expandKnob');
this._setExpand(false);
+ this.$.ink.hidden = true;
},
_positionKnob: function(ratio) {
- this._setImmediateValue(this._calcStep(this._calcKnobPosition(ratio)) || 0);
- this._setRatio(this.snaps ? this._calcRatio(this.immediateValue) : ratio);
- this.$.sliderKnob.style.left = this.ratio * 100 + '%';
+ this._setImmediateValue(this._calcStep(this._calcKnobPosition(ratio)));
+ this._setRatio(this._calcRatio(this.immediateValue));
+
+ this.$.sliderKnob.style.left = (this.ratio * 100) + '%';
},
_inputChange: function() {
@@ -328,75 +366,104 @@ To change the slider disabled secondary progress bar color:
return (this.max - this.min) * ratio + this.min;
},
- _onTrack: function(e) {
+ _onTrack: function(event) {
switch (event.detail.state) {
- case 'end':
- this._trackEnd(event);
+ case 'start':
+ this._trackStart(event);
break;
case 'track':
this._trackX(event);
break;
- case 'start':
- this._trackStart(event);
+ case 'end':
+ this._trackEnd();
break;
}
},
- _trackStart: function(e) {
+ _trackStart: function(event) {
this._w = this.$.sliderBar.offsetWidth;
this._x = this.ratio * this._w;
this._startx = this._x || 0;
this._minx = - this._startx;
this._maxx = this._w - this._startx;
this.$.sliderKnob.classList.add('dragging');
+
this._setDragging(true);
- e.preventDefault();
},
_trackX: function(e) {
if (!this.dragging) {
this._trackStart(e);
}
- var x = Math.min(this._maxx, Math.max(this._minx, e.detail.dx));
- this._x = this._startx + x;
- this._setImmediateValue(this._calcStep(
- this._calcKnobPosition(this._x / this._w)) || 0);
- var s = this.$.sliderKnob.style;
- s.transform = s.webkitTransform = 'translate3d(' + (this.snaps ?
- (this._calcRatio(this.immediateValue) * this._w) - this._startx : x) + 'px, 0, 0)';
+
+ var dx = Math.min(this._maxx, Math.max(this._minx, e.detail.dx));
+ this._x = this._startx + dx;
+
+ var immediateValue = this._calcStep(this._calcKnobPosition(this._x / this._w));
+ this._setImmediateValue(immediateValue);
+
+ // update knob's position
+ var translateX = ((this._calcRatio(immediateValue) * this._w) - this._startx);
+ this.translate3d(translateX + 'px', 0, 0, this.$.sliderKnob);
},
_trackEnd: function() {
- var s = this.$.sliderKnob.style;
- s.transform = s.webkitTransform = '';
+ var s = this.$.sliderKnob.style;
+
this.$.sliderKnob.classList.remove('dragging');
this._setDragging(false);
this._resetKnob();
this.value = this.immediateValue;
+
+ s.transform = s.webkitTransform = '';
+
this.fire('change');
},
- _knobdown: function(e) {
- e.preventDefault();
+ _knobdown: function(event) {
this._expandKnob();
+
+ // cancel selection
+ event.detail.sourceEvent.preventDefault();
+
+ // set the focus manually because we will called prevent default
+ this.focus();
},
- _bardown: function(e) {
- e.preventDefault();
- this._setTransiting(true);
+ _bardown: function(event) {
+ this.$.ink.hidden = true;
+
+ event.preventDefault();
+
this._w = this.$.sliderBar.offsetWidth;
var rect = this.$.sliderBar.getBoundingClientRect();
- var ratio = (e.detail.x - rect.left) / this._w;
+ var ratio = (event.detail.x - rect.left) / this._w;
+ var prevRatio = this.ratio;
+
+ this._setTransiting(true);
+
this._positionKnob(ratio);
- this._expandJob = this.debounce(this._expandJob, this._expandKnob, 60);
+
+ this.debounce('expandKnob', this._expandKnob, 60);
+
+ // if the ratio doesn't change, sliderKnob's animation won't start
+ // and `_knobTransitionEnd` won't be called
+ // Therefore, we need to manually update the `transiting` state
+
+ if (prevRatio === this.ratio) {
+ this._setTransiting(false);
+ }
this.async(function() {
this.fire('change');
});
+
+ // cancel selection
+ event.detail.sourceEvent.preventDefault();
},
- _knobTransitionEnd: function(e) {
- if (e.target === this.$.sliderKnob) {
+ _knobTransitionEnd: function(event) {
+ if (event.target === this.$.sliderKnob) {
this._setTransiting(false);
}
},
@@ -413,14 +480,14 @@ To change the slider disabled secondary progress bar color:
_getClassNames: function() {
var classes = {};
- classes['disabled'] = this.disabled;
- classes['pin'] = this.pin;
- classes['snaps'] = this.snaps;
- classes['ring'] = this.immediateValue <= this.min;
- classes['expand'] = this.expand;
- classes['dragging'] = this.dragging;
- classes['transiting'] = this.transiting;
- classes['editable'] = this.editable;
+ classes.disabled = this.disabled;
+ classes.pin = this.pin;
+ classes.snaps = this.snaps;
+ classes.ring = this.immediateValue <= this.min;
+ classes.expand = this.expand;
+ classes.dragging = this.dragging;
+ classes.transiting = this.transiting;
+ classes.editable = this.editable;
return Object.keys(classes).filter(
function(className) {
@@ -428,8 +495,8 @@ To change the slider disabled secondary progress bar color:
}).join(' ');
},
- _incrementKey: function(ev, keys) {
- if (keys.key === 'end') {
+ _incrementKey: function(event) {
+ if (event.detail.key === 'end') {
this.value = this.max;
} else {
this.increment();
@@ -437,8 +504,8 @@ To change the slider disabled secondary progress bar color:
this.fire('change');
},
- _decrementKey: function(ev, keys) {
- if (keys.key === 'home') {
+ _decrementKey: function(event) {
+ if (event.detail.key === 'home') {
this.value = this.min;
} else {
this.decrement();

Powered by Google App Engine
This is Rietveld 408576698