Skip to content

Commit

Permalink
Fixed issues/934 - added required Rect with zeros
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrey Lobanov committed Dec 1, 2022
1 parent 9c280e4 commit 5b87b62
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions packages/@interactjs/utils/domUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,16 +213,25 @@ export function getElementClientRect (element: Element): Required<Rect> {
const clientRect =
element instanceof domObjects.SVGElement ? element.getBoundingClientRect() : element.getClientRects()[0]

return (
clientRect && {
left: clientRect.left,
right: clientRect.right,
top: clientRect.top,
bottom: clientRect.bottom,
width: clientRect.width || clientRect.right - clientRect.left,
height: clientRect.height || clientRect.bottom - clientRect.top,
if (clientRect) {
return {
left: clientRect.left,
right: clientRect.right,
top: clientRect.top,
bottom: clientRect.bottom,
width: clientRect.width || clientRect.right - clientRect.left,
height: clientRect.height || clientRect.bottom - clientRect.top,
};
}
)

return {
left: 0,
right: 0,
top: 0,
bottom: 0,
width: 0,
height: 0,
};
}

export function getElementRect (element: Element) {
Expand Down

0 comments on commit 5b87b62

Please sign in to comment.