Skip to content

Commit

Permalink
Remove jquery from documentScrollParent
Browse files Browse the repository at this point in the history
  • Loading branch information
mbraak committed Nov 18, 2023
1 parent f32b835 commit e22f315
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/scrollHandler/documentScrollParent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ interface Params {
}

export default class DocumentScrollParent implements ScrollParent {
private documentScrollHeight?: number;
private documentScrollWidth?: number;
private horizontalScrollDirection?: HorizontalScrollDirection;
private horizontalScrollTimeout?: number;
private refreshHitAreas: () => void;
private treeElement: HTMLElement;
private verticalScrollDirection?: VerticalScrollDirection;
private verticalScrollTimeout?: number;
private documentScrollHeight?: number;
private documentScrollWidth?: number;

constructor({ refreshHitAreas, treeElement }: Params) {
this.refreshHitAreas = refreshHitAreas;
Expand Down Expand Up @@ -72,7 +72,7 @@ export default class DocumentScrollParent implements ScrollParent {
public scrollToY(top: number): void {
const treeTop = getOffsetTop(this.treeElement);

jQuery(document).scrollTop(top + treeTop);
document.documentElement.scrollTop = top + treeTop;
}

public stopScrolling() {
Expand All @@ -85,10 +85,8 @@ export default class DocumentScrollParent implements ScrollParent {
private getNewHorizontalScrollDirection(
pageX: number,
): HorizontalScrollDirection | undefined {
const $document = jQuery(document);

const scrollLeft = $document.scrollLeft() || 0;
const windowWidth = jQuery(window).width() || 0;
const scrollLeft = document.documentElement.scrollLeft;
const windowWidth = window.innerWidth;

const isNearRightEdge = pageX > windowWidth - 20;
const isNearLeftEdge = pageX - scrollLeft < 20;
Expand Down Expand Up @@ -150,7 +148,7 @@ export default class DocumentScrollParent implements ScrollParent {
return "top";
}

const windowHeight = jQuery(window).height() || 0;
const windowHeight = window.innerHeight;

if (windowHeight - (pageY - scrollTop) < 20 && this.canScrollDown()) {
return "bottom";
Expand Down

0 comments on commit e22f315

Please sign in to comment.