| 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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 '_immediateValueChanged(immediateValue)', | 107 '_immediateValueChanged(immediateValue)', |
| 108 '_updateMarkers(maxMarkers, min, max, snaps)' | 108 '_updateMarkers(maxMarkers, min, max, snaps)' |
| 109 ], | 109 ], |
| 110 | 110 |
| 111 hostAttributes: { | 111 hostAttributes: { |
| 112 role: 'slider', | 112 role: 'slider', |
| 113 tabindex: 0 | 113 tabindex: 0 |
| 114 }, | 114 }, |
| 115 | 115 |
| 116 keyBindings: { | 116 keyBindings: { |
| 117 'left down pagedown home': '_decrementKey', | 117 'left down pagedown home': '_leftKey', |
| 118 'right up pageup end': '_incrementKey' | 118 'right up pageup end': '_rightKey' |
| 119 }, | 119 }, |
| 120 | 120 |
| 121 /** | 121 /** |
| 122 * Increases value by `step` but not above `max`. | 122 * Increases value by `step` but not above `max`. |
| 123 * @method increment | 123 * @method increment |
| 124 */ | 124 */ |
| 125 increment: function() { | 125 increment: function() { |
| 126 this.value = this._clampValue(this.value + this.step); | 126 this.value = this._clampValue(this.value + this.step); |
| 127 }, | 127 }, |
| 128 | 128 |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 this._maxx = this._w - this._startx; | 206 this._maxx = this._w - this._startx; |
| 207 this.$.sliderKnob.classList.add('dragging'); | 207 this.$.sliderKnob.classList.add('dragging'); |
| 208 this._setDragging(true); | 208 this._setDragging(true); |
| 209 }, | 209 }, |
| 210 | 210 |
| 211 _trackX: function(event) { | 211 _trackX: function(event) { |
| 212 if (!this.dragging) { | 212 if (!this.dragging) { |
| 213 this._trackStart(event); | 213 this._trackStart(event); |
| 214 } | 214 } |
| 215 | 215 |
| 216 var dx = Math.min(this._maxx, Math.max(this._minx, event.detail.dx)); | 216 var direction = this._isRTL ? -1 : 1; |
| 217 var dx = Math.min( |
| 218 this._maxx, Math.max(this._minx, event.detail.dx * direction)); |
| 217 this._x = this._startx + dx; | 219 this._x = this._startx + dx; |
| 218 | 220 |
| 219 var immediateValue = this._calcStep(this._calcKnobPosition(this._x / thi
s._w)); | 221 var immediateValue = this._calcStep(this._calcKnobPosition(this._x / thi
s._w)); |
| 220 this._setImmediateValue(immediateValue); | 222 this._setImmediateValue(immediateValue); |
| 221 | 223 |
| 222 // update knob's position | 224 // update knob's position |
| 223 var translateX = ((this._calcRatio(this.immediateValue) * this._w) - thi
s._knobstartx); | 225 var translateX = ((this._calcRatio(this.immediateValue) * this._w) - thi
s._knobstartx); |
| 224 this.translate3d(translateX + 'px', 0, 0, this.$.sliderKnob); | 226 this.translate3d(translateX + 'px', 0, 0, this.$.sliderKnob); |
| 225 }, | 227 }, |
| 226 | 228 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 pin: this.pin, | 310 pin: this.pin, |
| 309 snaps: this.snaps, | 311 snaps: this.snaps, |
| 310 ring: this.immediateValue <= this.min, | 312 ring: this.immediateValue <= this.min, |
| 311 expand: this.expand, | 313 expand: this.expand, |
| 312 dragging: this.dragging, | 314 dragging: this.dragging, |
| 313 transiting: this.transiting, | 315 transiting: this.transiting, |
| 314 editable: this.editable | 316 editable: this.editable |
| 315 }); | 317 }); |
| 316 }, | 318 }, |
| 317 | 319 |
| 318 _incrementKey: function(event) { | 320 get _isRTL() { |
| 321 if (this.__isRTL === undefined) { |
| 322 this.__isRTL = window.getComputedStyle(this)['direction'] === 'rtl'; |
| 323 } |
| 324 return this.__isRTL; |
| 325 }, |
| 326 |
| 327 _leftKey: function(event) { |
| 328 if (this._isRTL) |
| 329 this._incrementKey(event, 'home'); |
| 330 else |
| 331 this._decrementKey(event, 'home'); |
| 332 }, |
| 333 |
| 334 _rightKey: function(event) { |
| 335 if (this._isRTL) |
| 336 this._decrementKey(event, 'end'); |
| 337 else |
| 338 this._incrementKey(event, 'end'); |
| 339 }, |
| 340 |
| 341 _incrementKey: function(event, allTheWayKey) { |
| 319 if (!this.disabled) { | 342 if (!this.disabled) { |
| 320 if (event.detail.key === 'end') { | 343 if (event.detail.key === allTheWayKey) { |
| 321 this.value = this.max; | 344 this.value = this.max; |
| 322 } else { | 345 } else { |
| 323 this.increment(); | 346 this.increment(); |
| 324 } | 347 } |
| 325 this.fire('change'); | 348 this.fire('change'); |
| 326 event.preventDefault(); | 349 event.preventDefault(); |
| 327 } | 350 } |
| 328 }, | 351 }, |
| 329 | 352 |
| 330 _decrementKey: function(event) { | 353 _decrementKey: function(event, allTheWayKey) { |
| 331 if (!this.disabled) { | 354 if (!this.disabled) { |
| 332 if (event.detail.key === 'home') { | 355 if (event.detail.key === allTheWayKey) { |
| 333 this.value = this.min; | 356 this.value = this.min; |
| 334 } else { | 357 } else { |
| 335 this.decrement(); | 358 this.decrement(); |
| 336 } | 359 } |
| 337 this.fire('change'); | 360 this.fire('change'); |
| 338 event.preventDefault(); | 361 event.preventDefault(); |
| 339 } | 362 } |
| 340 }, | 363 }, |
| 341 | 364 |
| 342 _changeValue: function(event) { | 365 _changeValue: function(event) { |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 */ | 414 */ |
| 392 | 415 |
| 393 /** | 416 /** |
| 394 * Fired when the slider's value changes due to user interaction. | 417 * Fired when the slider's value changes due to user interaction. |
| 395 * | 418 * |
| 396 * Changes to the slider's value due to changes in an underlying | 419 * Changes to the slider's value due to changes in an underlying |
| 397 * bound variable will not trigger this event. | 420 * bound variable will not trigger this event. |
| 398 * | 421 * |
| 399 * @event change | 422 * @event change |
| 400 */ | 423 */ |
| OLD | NEW |