Skip to content

Commit

Permalink
Fix issues with scrolling
Browse files Browse the repository at this point in the history
  • Loading branch information
simonwep committed Jan 4, 2023
1 parent 96189f1 commit 5f284dc
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions packages/vanilla/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -381,16 +381,16 @@ export default class SelectionArea extends EventTarget<SelectionEvents> {
}

// Reduce velocity, use ceil in both directions to scroll at least 1px per frame
const {scrollTop, scrollLeft} = _targetElement;

if (_scrollSpeed.y) {
const distance = ceil(_scrollSpeed.y / speedDivider);
_targetElement.scrollTop += distance;
_areaLocation.y1 -= distance;
_targetElement.scrollTop += ceil(_scrollSpeed.y / speedDivider);
_areaLocation.y1 -= _targetElement.scrollTop - scrollTop;
}

if (_scrollSpeed.x) {
const distance = ceil(_scrollSpeed.x / speedDivider);
_targetElement.scrollLeft += distance;
_areaLocation.x1 -= distance;
_targetElement.scrollLeft += ceil(_scrollSpeed.x / speedDivider);
_areaLocation.x1 -= _targetElement.scrollLeft - scrollLeft;
}

/**
Expand Down

0 comments on commit 5f284dc

Please sign in to comment.