Skip to content

Commit

Permalink
fix: fix body rect #800
Browse files Browse the repository at this point in the history
  • Loading branch information
daybrush committed Nov 28, 2022
1 parent 11408ca commit 8976985
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions packages/react-moveable/src/react-moveable/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -865,24 +865,24 @@ export function getClientRect(el: HTMLElement | SVGElement, isExtends?: boolean)
let top = 0;
let width = 0;
let height = 0;
let isRoot = false;
// let isRoot = false;

if (el) {
isRoot = el === document.body || el === document.documentElement;
if (isRoot) {
width = window.innerWidth;
height = window.innerHeight;
const scrollPos = getBodyScrollPos();

[left, top] = [-scrollPos[0], -scrollPos[1]];
} else {
const clientRect = el.getBoundingClientRect();

left = clientRect.left;
top = clientRect.top;
width = clientRect.width;
height = clientRect.height;
}
// isRoot = el === document.body || el === document.documentElement;
// if (isRoot) {
// width = window.innerWidth;
// height = window.innerHeight;
// const scrollPos = getBodyScrollPos();

// [left, top] = [-scrollPos[0], -scrollPos[1]];
// } else {
const clientRect = el.getBoundingClientRect();

left = clientRect.left;
top = clientRect.top;
width = clientRect.width;
height = clientRect.height;
// }
}

const rect: MoveableClientRect = {
Expand Down

0 comments on commit 8976985

Please sign in to comment.