Skip to content

Commit

Permalink
fix(esl-scrollbar): fix esl:change:scroll event handler invoked befor…
Browse files Browse the repository at this point in the history
…e scrollbar updates
  • Loading branch information
dshovchko committed Nov 17, 2023
1 parent 6384844 commit 0c9c952
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/modules/esl-scrollbar/core/esl-scrollbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ export class ESLScrollbar extends ESLBaseElement {

public set position(position: number) {
this.scrollTargetTo(this.scrollableSize * this.normalizePosition(position));
this.update();
this.refresh();
}

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

/** Updates thumb size and position */
public update(): void {
this.$$fire('esl:change:scroll', {bubbles: false});
if (!this.$scrollbarThumb || !this.$scrollbarTrack) return;
const thumbSize = this.trackOffset * this.thumbSize;
const thumbPosition = (this.trackOffset - thumbSize) * this.position;
Expand All @@ -221,6 +220,7 @@ export class ESLScrollbar extends ESLBaseElement {
public refresh(): void {
this.update();
this.updateMarkers();
this.$$fire('esl:change:scroll', {bubbles: false});
}

/** Returns position from MouseEvent coordinates (not normalized) */
Expand Down Expand Up @@ -289,8 +289,6 @@ export class ESLScrollbar extends ESLBaseElement {
const scrollableAreaHeight = this.trackOffset - this.thumbOffset;
const absChange = scrollableAreaHeight ? (positionChange / scrollableAreaHeight) : 0;
this.position = this._initialPosition + absChange;

this.updateMarkers();
}

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

0 comments on commit 0c9c952

Please sign in to comment.