| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * @fileoverview | 6 * @fileoverview |
| 7 * settings-slider wraps a paper-slider. It maps the slider's values from a | 7 * settings-slider wraps a paper-slider. It maps the slider's values from a |
| 8 * linear UI range to a range of real values. When |value| does not map exactly | 8 * linear UI range to a range of real values. When |value| does not map exactly |
| 9 * to a tick mark, it interpolates to the nearest tick. | 9 * to a tick mark, it interpolates to the nearest tick. |
| 10 * | 10 * |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 observers: [ | 43 observers: [ |
| 44 'valueChanged_(pref.*, tickValues.*)', | 44 'valueChanged_(pref.*, tickValues.*)', |
| 45 ], | 45 ], |
| 46 | 46 |
| 47 /** | 47 /** |
| 48 * Sets the |pref.value| property to the value corresponding to the knob | 48 * Sets the |pref.value| property to the value corresponding to the knob |
| 49 * position after a user action. | 49 * position after a user action. |
| 50 * @private | 50 * @private |
| 51 */ | 51 */ |
| 52 onSliderChanged_: function() { | 52 onSliderChanged_: function() { |
| 53 var sliderValue = isNaN(this.$.slider.immediateValue) |
| 54 ? this.$.slider.value |
| 55 : this.$.slider.immediateValue; |
| 56 |
| 53 var newValue; | 57 var newValue; |
| 54 if (this.tickValues && this.tickValues.length > 0) | 58 if (this.tickValues && this.tickValues.length > 0) |
| 55 newValue = this.tickValues[this.$.slider.immediateValue]; | 59 newValue = this.tickValues[sliderValue]; |
| 56 else | 60 else |
| 57 newValue = this.$.slider.immediateValue; | 61 newValue = sliderValue; |
| 58 | 62 |
| 59 this.set('pref.value', newValue); | 63 this.set('pref.value', newValue); |
| 60 }, | 64 }, |
| 61 | 65 |
| 62 /** @private */ | 66 /** @private */ |
| 63 computeDisableSlider_: function() { | 67 computeDisableSlider_: function() { |
| 64 return this.disabled || this.isPrefEnforced(); | 68 return this.disabled || this.isPrefEnforced(); |
| 65 }, | 69 }, |
| 66 | 70 |
| 67 /** | 71 /** |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 if (difference < minDifference) { | 130 if (difference < minDifference) { |
| 127 closestIndex = i; | 131 closestIndex = i; |
| 128 minDifference = difference; | 132 minDifference = difference; |
| 129 } | 133 } |
| 130 } | 134 } |
| 131 | 135 |
| 132 assert(typeof closestIndex != 'undefined'); | 136 assert(typeof closestIndex != 'undefined'); |
| 133 return closestIndex; | 137 return closestIndex; |
| 134 }, | 138 }, |
| 135 }); | 139 }); |
| OLD | NEW |