Skip to content

Commit a485770

Browse files
committed
Fix code reviews proposals
1 parent c9c0e0b commit a485770

File tree

6 files changed

+105
-142
lines changed

6 files changed

+105
-142
lines changed

packages/main/src/Slider.js

+16-20
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,6 @@ class Slider extends SliderBase {
8080
return SliderTemplate;
8181
}
8282

83-
static get styles() {
84-
return super.styles;
85-
}
86-
8783
constructor() {
8884
super();
8985
this._stateStorage.value = null;
@@ -108,7 +104,7 @@ class Slider extends SliderBase {
108104

109105
this.notResized = true;
110106
this.syncUIAndState("value");
111-
this._updateUI(this.value);
107+
this._updateHandleAndProgress(this.value);
112108
}
113109

114110
/**
@@ -123,11 +119,11 @@ class Slider extends SliderBase {
123119
return;
124120
}
125121

126-
const newValue = this.handleDownBase(event, this.min, this.max);
122+
const newValue = this.handleDownBase(event, this._effectiveMin, this._effectiveMax);
127123

128124
// Do not yet update the Slider if press is over a handle. It will be updated if the user drags the mouse.
129-
if (!this._isHandlePressed(SliderBase.getPageXValueFromEvent(event))) {
130-
this._updateUI(newValue);
125+
if (!this._isHandlePressed(this.constructor.getPageXValueFromEvent(event))) {
126+
this._updateHandleAndProgress(newValue);
131127
this.updateValue("value", newValue);
132128
}
133129
}
@@ -142,13 +138,13 @@ class Slider extends SliderBase {
142138

143139
// If step is 0 no interaction is available because there is no constant
144140
// (equal for all user environments) quantitative representation of the value
145-
if (this.disabled || this.step === 0) {
141+
if (this.disabled || this._effectiveStep === 0) {
146142
return;
147143
}
148144

149-
const newValue = SliderBase.getValueFromInteraction(event, this.step, this.min, this.max, this.getBoundingClientRect(), this.directionStart);
145+
const newValue = this.constructor.getValueFromInteraction(event, this._effectiveStep, this._effectiveMin, this._effectiveMax, this.getBoundingClientRect(), this.directionStart);
150146

151-
this._updateUI(newValue);
147+
this._updateHandleAndProgress(newValue);
152148
this.updateValue("value", newValue);
153149
}
154150

@@ -172,31 +168,31 @@ class Slider extends SliderBase {
172168
}
173169

174170

175-
/** Updates the UI representation of the Slider according to its internal state.
171+
/** Updates the UI representation of the progress bar and handle position
176172
*
177173
* @private
178174
*/
179-
_updateUI(newValue) {
180-
const max = this.max;
181-
const min = this.min;
175+
_updateHandleAndProgress(newValue) {
176+
const max = this._effectiveMax;
177+
const min = this._effectiveMin;
182178

183179
// The progress (completed) percentage of the slider.
184-
this._percentageComplete = (newValue - min) / (max - min);
180+
this._progressPercentage = (newValue - min) / (max - min);
185181
// How many pixels from the left end of the slider will be the placed the affected by the user action handle
186-
this._handlePositionFromStart = this._percentageComplete * 100;
182+
this._handlePositionFromStart = this._progressPercentage * 100;
187183
}
188184

189185
get styles() {
190186
return {
191187
progress: {
192-
"transform": `scaleX(${this._percentageComplete})`,
188+
"transform": `scaleX(${this._progressPercentage})`,
193189
"transform-origin": `${this.directionStart} top`,
194190
},
195191
handle: {
196192
[this.directionStart]: `${this._handlePositionFromStart}%`,
197193
},
198194
tickmarks: {
199-
"background": `${this._tickmarksBackground}`,
195+
"background": `${this._tickmarks}`,
200196
},
201197
label: {
202198
"width": `${this._labelWidth}%`,
@@ -216,7 +212,7 @@ class Slider extends SliderBase {
216212
}
217213

218214
get tooltipValue() {
219-
const stepPrecision = SliderBase._getDecimalPrecisionOfNumber(this.step);
215+
const stepPrecision = this.constructor._getDecimalPrecisionOfNumber(this._effectiveStep);
220216
return this.value.toFixed(stepPrecision);
221217
}
222218

packages/main/src/SliderBase.hbs

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
class="ui5-slider-root"
33
@mousedown="{{_onmousedown}}"
44
@touchstart="{{_ontouchstart}}"
5-
@pointerdown="{{_onpointerdown}}"
65
@mouseover="{{_onmouseover}}"
76
@mouseout="{{_onmouseout}}"
87
dir="{{effectiveDir}}"
@@ -17,7 +16,7 @@
1716
<div class="ui5-slider-tickmarks" style="{{styles.tickmarks}}"></div>
1817
{{#if labelInterval}}
1918
<ul class="ui5-slider-labels {{classes.labelContainer}}" style="{{styles.labelContainer}}">
20-
{{#each labelItems}}
19+
{{#each _labels}}
2120
<li style="{{../styles.label}}">{{this}}</li>
2221
{{/each}}
2322
</ul>

0 commit comments

Comments
 (0)