Skip to content

Commit 237092a

Browse files
authored
Merge pull request #2058 from exadel-inc/fix/esl-scrollbar-event
fix(esl-scrollbar): fix esl:change:scroll event handler invoked before scrollbar updates
2 parents 6384844 + 0c9c952 commit 237092a

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

Diff for: src/modules/esl-scrollbar/core/esl-scrollbar.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ export class ESLScrollbar extends ESLBaseElement {
177177

178178
public set position(position: number) {
179179
this.scrollTargetTo(this.scrollableSize * this.normalizePosition(position));
180-
this.update();
180+
this.refresh();
181181
}
182182

183183
/** Normalizes position value (between 0.0 and 1.0) */
@@ -198,7 +198,6 @@ export class ESLScrollbar extends ESLBaseElement {
198198

199199
/** Updates thumb size and position */
200200
public update(): void {
201-
this.$$fire('esl:change:scroll', {bubbles: false});
202201
if (!this.$scrollbarThumb || !this.$scrollbarTrack) return;
203202
const thumbSize = this.trackOffset * this.thumbSize;
204203
const thumbPosition = (this.trackOffset - thumbSize) * this.position;
@@ -221,6 +220,7 @@ export class ESLScrollbar extends ESLBaseElement {
221220
public refresh(): void {
222221
this.update();
223222
this.updateMarkers();
223+
this.$$fire('esl:change:scroll', {bubbles: false});
224224
}
225225

226226
/** Returns position from MouseEvent coordinates (not normalized) */
@@ -289,8 +289,6 @@ export class ESLScrollbar extends ESLBaseElement {
289289
const scrollableAreaHeight = this.trackOffset - this.thumbOffset;
290290
const absChange = scrollableAreaHeight ? (positionChange / scrollableAreaHeight) : 0;
291291
this.position = this._initialPosition + absChange;
292-
293-
this.updateMarkers();
294292
}
295293

296294
/** `mousemove` document handler for thumb drag event. Active only if drag action is active */

0 commit comments

Comments
 (0)