Skip to content

Commit 9c71bb3

Browse files
authored
Merge pull request #5 from ilya-cherepanov/master
2 parents a38034f + ba2668c commit 9c71bb3

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

source/scripts/index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,11 @@ class Slider {
143143
}
144144

145145
set currentState(newState) {
146-
this._currentState = Math.max(0, Math.min(newState, 1));
146+
const updatedState = Math.max(0, Math.min(newState, 1));
147+
const isNeedUpdate = updatedState !== this._currentState;
148+
this._currentState = updatedState;
147149

148-
if (this._rafId === null) {
150+
if (this._rafId === null && isNeedUpdate) {
149151
this._rafId = requestAnimationFrame(() => {
150152
this._sliderElement.style.setProperty('--slider-state', this._currentState);
151153
this._rafId = null;

0 commit comments

Comments
 (0)