Skip to content

Commit

Permalink
fix(esl-scrollbar): fix incorrect at-start/at-end handling when b…
Browse files Browse the repository at this point in the history
…rowser creates dimensions with the floating point

Resolved by adding `1px` tolerance of position boundary values
  • Loading branch information
ala-n committed Oct 10, 2023
1 parent 166d3ff commit 852ad15
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/modules/esl-scrollbar/core/esl-scrollbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,12 @@ export class ESLScrollbar extends ESLBaseElement {
/** Relative position value (between 0.0 and 1.0) */
public get position(): number {
if (!this.$target) return 0;
const scrollOffset = this.horizontal ? normalizeScrollLeft(this.$target) : this.$target.scrollTop;
return this.scrollableSize ? (scrollOffset / this.scrollableSize) : 0;
const size = this.scrollableSize;
if (size <= 0) return 0;
const offset = this.horizontal ? normalizeScrollLeft(this.$target) : this.$target.scrollTop;
if (offset < 1) return 0;
if (offset >= size - 1) return 1;
return offset / size;
}

public set position(position: number) {
Expand Down

0 comments on commit 852ad15

Please sign in to comment.