Skip to content

Commit

Permalink
fix: use width/height of window instead of document
Browse files Browse the repository at this point in the history
  • Loading branch information
wqcstrong committed Dec 5, 2023
1 parent 572bb06 commit 7c702c5
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/utils/moveable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,19 @@ export function moveable(el: HTMLElement) {
evt.preventDefault();
(el as UElement).isMoveEvent = false;
rect = el.getBoundingClientRect();
critical.xAxis = document.documentElement.offsetWidth - rect.width;
critical.yAxis = document.documentElement.offsetHeight - rect.height;
critical.xAxis = window.innerWidth - rect.width;
critical.yAxis = window.innerHeight - rect.height;

const { clientX, clientY } = getPosition(evt);
touch.x = clientX;
touch.y = clientY;
document.addEventListener('mousemove', move, false);
document.addEventListener('mouseup', end, false);

document.addEventListener('touchmove', move, { capture: false, passive: false });
document.addEventListener('touchmove', move, {
capture: false,
passive: false,
});
document.addEventListener('touchend', end, false);
}

Expand Down

0 comments on commit 7c702c5

Please sign in to comment.