Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix: scroll handler class indexing of HTMLElement with TS
  • Loading branch information
joshuaellis committed Apr 10, 2023
commit 6261ddc413eb9ef498b0c25f5dcb5a0ea0397dfe
7 changes: 5 additions & 2 deletions packages/shared/src/dom-events/scroll/ScrollHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ export interface ScrollInfo {
y: ScrollAxis
}

type ScrollKeys = 'scrollHeight' | 'scrollWidth' | 'scrollLeft' | 'scrollTop'

/**
* Why use a class? More extensible in the future.
*/
Expand Down Expand Up @@ -58,9 +60,10 @@ export class ScrollHandler {
const axis = this.info[axisName]
const { length, position } = SCROLL_KEYS[axisName]

axis.current = this.container[`scroll${position}`]
axis.current = this.container[`scroll${position}` as ScrollKeys]
axis.scrollLength =
this.container['scroll' + length] - this.container['client' + length]
this.container[('scroll' + length) as ScrollKeys] -
this.container[('client' + length) as ScrollKeys]

axis.progress = progress(0, axis.scrollLength, axis.current)
}
Expand Down