| 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 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 if (prevRatio === this.ratio) { | 271 if (prevRatio === this.ratio) { |
| 272 this._setTransiting(false); | 272 this._setTransiting(false); |
| 273 } | 273 } |
| 274 | 274 |
| 275 this.async(function() { | 275 this.async(function() { |
| 276 this.fire('change'); | 276 this.fire('change'); |
| 277 }); | 277 }); |
| 278 | 278 |
| 279 // cancel selection | 279 // cancel selection |
| 280 event.preventDefault(); | 280 event.preventDefault(); |
| 281 |
| 282 // set the focus manually because we will called prevent default |
| 283 this.focus(); |
| 281 }, | 284 }, |
| 282 | 285 |
| 283 _knobTransitionEnd: function(event) { | 286 _knobTransitionEnd: function(event) { |
| 284 if (event.target === this.$.sliderKnob) { | 287 if (event.target === this.$.sliderKnob) { |
| 285 this._setTransiting(false); | 288 this._setTransiting(false); |
| 286 } | 289 } |
| 287 }, | 290 }, |
| 288 | 291 |
| 289 _maxMarkersChanged: function(maxMarkers) { | 292 _maxMarkersChanged: function(maxMarkers) { |
| 290 if (!this.snaps) { | 293 if (!this.snaps) { |
| 291 this._setMarkers([]); | 294 this._setMarkers([]); |
| 292 } | 295 } |
| 293 var steps = Math.floor((this.max - this.min) / this.step); | 296 var steps = Math.round((this.max - this.min) / this.step); |
| 294 if (steps > maxMarkers) { | 297 if (steps > maxMarkers) { |
| 295 steps = maxMarkers; | 298 steps = maxMarkers; |
| 296 } | 299 } |
| 297 this._setMarkers(new Array(steps)); | 300 this._setMarkers(new Array(steps)); |
| 298 }, | 301 }, |
| 299 | 302 |
| 300 _mergeClasses: function(classes) { | 303 _mergeClasses: function(classes) { |
| 301 return Object.keys(classes).filter( | 304 return Object.keys(classes).filter( |
| 302 function(className) { | 305 function(className) { |
| 303 return classes[className]; | 306 return classes[className]; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 // Hide the ripple when user is not interacting with keyboard. | 360 // Hide the ripple when user is not interacting with keyboard. |
| 358 // This behavior is different from other ripple-y controls, but is | 361 // This behavior is different from other ripple-y controls, but is |
| 359 // according to spec: https://www.google.com/design/spec/components/slider
s.html | 362 // according to spec: https://www.google.com/design/spec/components/slider
s.html |
| 360 _focusedChanged: function(receivedFocusFromKeyboard) { | 363 _focusedChanged: function(receivedFocusFromKeyboard) { |
| 361 if (receivedFocusFromKeyboard) { | 364 if (receivedFocusFromKeyboard) { |
| 362 this.ensureRipple(); | 365 this.ensureRipple(); |
| 363 } | 366 } |
| 364 if (this.hasRipple()) { | 367 if (this.hasRipple()) { |
| 365 // note, ripple must be un-hidden prior to setting `holdDown` | 368 // note, ripple must be un-hidden prior to setting `holdDown` |
| 366 if (receivedFocusFromKeyboard) { | 369 if (receivedFocusFromKeyboard) { |
| 367 this._ripple.removeAttribute('hidden'); | 370 this._ripple.style.display = ''; |
| 368 } else { | 371 } else { |
| 369 this._ripple.setAttribute('hidden', ''); | 372 this._ripple.style.display = 'none'; |
| 370 } | 373 } |
| 371 this._ripple.holdDown = receivedFocusFromKeyboard; | 374 this._ripple.holdDown = receivedFocusFromKeyboard; |
| 372 } | 375 } |
| 373 } | 376 } |
| 374 }); | 377 }); |
| 375 | 378 |
| 376 /** | 379 /** |
| 377 * Fired when the slider's value changes. | 380 * Fired when the slider's value changes. |
| 378 * | 381 * |
| 379 * @event value-change | 382 * @event value-change |
| 380 */ | 383 */ |
| 381 | 384 |
| 382 /** | 385 /** |
| 383 * Fired when the slider's immediateValue changes. | 386 * Fired when the slider's immediateValue changes. |
| 384 * | 387 * |
| 385 * @event immediate-value-change | 388 * @event immediate-value-change |
| 386 */ | 389 */ |
| 387 | 390 |
| 388 /** | 391 /** |
| 389 * Fired when the slider's value changes due to user interaction. | 392 * Fired when the slider's value changes due to user interaction. |
| 390 * | 393 * |
| 391 * Changes to the slider's value due to changes in an underlying | 394 * Changes to the slider's value due to changes in an underlying |
| 392 * bound variable will not trigger this event. | 395 * bound variable will not trigger this event. |
| 393 * | 396 * |
| 394 * @event change | 397 * @event change |
| 395 */ | 398 */ |
| OLD | NEW |