| OLD | NEW |
| 1 Polymer({ | 1 Polymer({ |
| 2 is: 'paper-slider', | 2 is: 'paper-slider', |
| 3 | 3 |
| 4 behaviors: [ | 4 behaviors: [ |
| 5 Polymer.IronA11yKeysBehavior, | 5 Polymer.IronA11yKeysBehavior, |
| 6 Polymer.IronFormElementBehavior, | 6 Polymer.IronFormElementBehavior, |
| 7 Polymer.PaperInkyFocusBehavior, | 7 Polymer.PaperInkyFocusBehavior, |
| 8 Polymer.IronRangeBehavior | 8 Polymer.IronRangeBehavior |
| 9 ], | 9 ], |
| 10 | 10 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 readOnly: true, | 58 readOnly: true, |
| 59 notify: true | 59 notify: true |
| 60 }, | 60 }, |
| 61 | 61 |
| 62 /** | 62 /** |
| 63 * The maximum number of markers | 63 * The maximum number of markers |
| 64 */ | 64 */ |
| 65 maxMarkers: { | 65 maxMarkers: { |
| 66 type: Number, | 66 type: Number, |
| 67 value: 0, | 67 value: 0, |
| 68 notify: true, | 68 notify: true |
| 69 observer: '_maxMarkersChanged' | |
| 70 }, | 69 }, |
| 71 | 70 |
| 72 /** | 71 /** |
| 73 * If true, the knob is expanded | 72 * If true, the knob is expanded |
| 74 */ | 73 */ |
| 75 expand: { | 74 expand: { |
| 76 type: Boolean, | 75 type: Boolean, |
| 77 value: false, | 76 value: false, |
| 78 readOnly: true | 77 readOnly: true |
| 79 }, | 78 }, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 96 markers: { | 95 markers: { |
| 97 type: Array, | 96 type: Array, |
| 98 readOnly: true, | 97 readOnly: true, |
| 99 value: [] | 98 value: [] |
| 100 }, | 99 }, |
| 101 }, | 100 }, |
| 102 | 101 |
| 103 observers: [ | 102 observers: [ |
| 104 '_updateKnob(value, min, max, snaps, step)', | 103 '_updateKnob(value, min, max, snaps, step)', |
| 105 '_valueChanged(value)', | 104 '_valueChanged(value)', |
| 106 '_immediateValueChanged(immediateValue)' | 105 '_immediateValueChanged(immediateValue)', |
| 106 '_updateMarkers(maxMarkers, min, max, snaps)' |
| 107 ], | 107 ], |
| 108 | 108 |
| 109 hostAttributes: { | 109 hostAttributes: { |
| 110 role: 'slider', | 110 role: 'slider', |
| 111 tabindex: 0 | 111 tabindex: 0 |
| 112 }, | 112 }, |
| 113 | 113 |
| 114 keyBindings: { | 114 keyBindings: { |
| 115 'left down pagedown home': '_decrementKey', | 115 'left down pagedown home': '_decrementKey', |
| 116 'right up pageup end': '_incrementKey' | 116 'right up pageup end': '_incrementKey' |
| 117 }, | 117 }, |
| 118 | 118 |
| 119 ready: function() { | |
| 120 // issue polymer/polymer#1305 | |
| 121 this.async(function() { | |
| 122 this._updateKnob(this.value); | |
| 123 }, 1); | |
| 124 }, | |
| 125 | |
| 126 /** | 119 /** |
| 127 * Increases value by `step` but not above `max`. | 120 * Increases value by `step` but not above `max`. |
| 128 * @method increment | 121 * @method increment |
| 129 */ | 122 */ |
| 130 increment: function() { | 123 increment: function() { |
| 131 this.value = this._clampValue(this.value + this.step); | 124 this.value = this._clampValue(this.value + this.step); |
| 132 }, | 125 }, |
| 133 | 126 |
| 134 /** | 127 /** |
| 135 * Decreases value by `step` but not below `min`. | 128 * Decreases value by `step` but not below `min`. |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 // set the focus manually because we will called prevent default | 275 // set the focus manually because we will called prevent default |
| 283 this.focus(); | 276 this.focus(); |
| 284 }, | 277 }, |
| 285 | 278 |
| 286 _knobTransitionEnd: function(event) { | 279 _knobTransitionEnd: function(event) { |
| 287 if (event.target === this.$.sliderKnob) { | 280 if (event.target === this.$.sliderKnob) { |
| 288 this._setTransiting(false); | 281 this._setTransiting(false); |
| 289 } | 282 } |
| 290 }, | 283 }, |
| 291 | 284 |
| 292 _maxMarkersChanged: function(maxMarkers) { | 285 _updateMarkers: function(maxMarkers, min, max, snaps) { |
| 293 if (!this.snaps) { | 286 if (!snaps) { |
| 294 this._setMarkers([]); | 287 this._setMarkers([]); |
| 295 } | 288 } |
| 296 var steps = Math.round((this.max - this.min) / this.step); | 289 var steps = Math.round((max - min) / this.step); |
| 297 if (steps > maxMarkers) { | 290 if (steps > maxMarkers) { |
| 298 steps = maxMarkers; | 291 steps = maxMarkers; |
| 299 } | 292 } |
| 300 this._setMarkers(new Array(steps)); | 293 this._setMarkers(new Array(steps)); |
| 301 }, | 294 }, |
| 302 | 295 |
| 303 _mergeClasses: function(classes) { | 296 _mergeClasses: function(classes) { |
| 304 return Object.keys(classes).filter( | 297 return Object.keys(classes).filter( |
| 305 function(className) { | 298 function(className) { |
| 306 return classes[className]; | 299 return classes[className]; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 } | 369 } |
| 377 }); | 370 }); |
| 378 | 371 |
| 379 /** | 372 /** |
| 380 * Fired when the slider's value changes. | 373 * Fired when the slider's value changes. |
| 381 * | 374 * |
| 382 * @event value-change | 375 * @event value-change |
| 383 */ | 376 */ |
| 384 | 377 |
| 385 /** | 378 /** |
| 386 * Fired when the slider's immediateValue changes. | 379 * Fired when the slider's immediateValue changes. Only occurs while the |
| 380 * user is dragging. |
| 381 * |
| 382 * To detect changes to immediateValue that happen for any input (i.e.
|
| 383 * dragging, tapping, clicking, etc.) listen for immediate-value-changed |
| 384 * instead. |
| 387 * | 385 * |
| 388 * @event immediate-value-change | 386 * @event immediate-value-change |
| 389 */ | 387 */ |
| 390 | 388 |
| 391 /** | 389 /** |
| 392 * Fired when the slider's value changes due to user interaction. | 390 * Fired when the slider's value changes due to user interaction. |
| 393 * | 391 * |
| 394 * Changes to the slider's value due to changes in an underlying | 392 * Changes to the slider's value due to changes in an underlying |
| 395 * bound variable will not trigger this event. | 393 * bound variable will not trigger this event. |
| 396 * | 394 * |
| 397 * @event change | 395 * @event change |
| 398 */ | 396 */ |
| OLD | NEW |