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 acded14
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 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 && {
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 acded14

Please sign in to comment.