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

Unified Diff: chrome/browser/resources/settings/controls/settings_slider.js

Issue 2877173002: Add scale to settings-slider (Closed)
Patch Set: . Created 3 years, 7 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: chrome/browser/resources/settings/controls/settings_slider.js
diff --git a/chrome/browser/resources/settings/controls/settings_slider.js b/chrome/browser/resources/settings/controls/settings_slider.js
index 1d7e2a94372ca4f788a7972bb1dc37e8c08cf372..fd121e3bbc6cbbece2b63443a8e2210d5185ba08 100644
--- a/chrome/browser/resources/settings/controls/settings_slider.js
+++ b/chrome/browser/resources/settings/controls/settings_slider.js
@@ -23,6 +23,13 @@ Polymer({
/** @type {!Array<number>} Values corresponding to each tick. */
tickValues: {type: Array, value: []},
+ /**
+ * |scale| is applied to the slider value if |tickValues| is empty,
michaelpg 2017/05/15 19:53:18 the pref value is being scaled, not the slider val
stevenjb 2017/05/15 21:45:09 No, it's the other way around, but I will clarify
michaelpg 2017/05/15 22:14:32 it's still confusing -- I think we're reading it i
stevenjb 2017/05/15 22:24:00 Dude, the code says: slider.value = pref.value *
michaelpg 2017/05/15 22:55:05 What term is multiplied by scale in this equation?
+ * otherwise it is ignored. Can be used to set fractional pref values
+ * (paper-slider will not set fractional values).
+ */
+ scale: Number,
+
min: Number,
max: Number,
@@ -57,6 +64,8 @@ Polymer({
var newValue;
if (this.tickValues && this.tickValues.length > 0)
newValue = this.tickValues[sliderValue];
+ else if (this.scale)
+ newValue = sliderValue / this.scale;
afakhry 2017/05/12 19:12:13 Is it possible to give |scale| a default value of
stevenjb 2017/05/12 20:14:13 It is, and I considered that, but this seemed slig
afakhry 2017/05/12 23:56:11 I'm fine with either way.
michaelpg 2017/05/15 19:53:18 Either way, I'd suggest an assert so it breaks if
stevenjb 2017/05/15 21:45:09 Done (assert placed in valueChanged where it is ea
else
newValue = sliderValue;
@@ -77,7 +86,12 @@ Polymer({
valueChanged_: function() {
// If |tickValues| is empty, simply set current value to the slider.
if (this.tickValues.length == 0) {
- this.$.slider.value = this.pref.value;
+ if (this.scale) {
michaelpg 2017/05/15 19:53:18 in the same vein as afakhry's chomment, this may b
stevenjb 2017/05/15 21:45:09 Set default scale to 1.
+ this.$.slider.value =
+ /** @type {number} */ (this.pref.value) * this.scale;
+ } else {
+ this.$.slider.value = this.pref.value;
+ }
return;
}

Powered by Google App Engine
This is Rietveld 408576698