Skip to content

Commit d2e46f9

Browse files
author
Andrey Lobanov
committed
Fixed issues/934 - added required Rect with zeros
1 parent 9c280e4 commit d2e46f9

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

packages/@interactjs/utils/domUtils.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,16 +213,25 @@ export function getElementClientRect (element: Element): Required<Rect> {
213213
const clientRect =
214214
element instanceof domObjects.SVGElement ? element.getBoundingClientRect() : element.getClientRects()[0]
215215

216-
return (
217-
clientRect && {
216+
if (clientRect) {
217+
return {
218218
left: clientRect.left,
219219
right: clientRect.right,
220220
top: clientRect.top,
221221
bottom: clientRect.bottom,
222222
width: clientRect.width || clientRect.right - clientRect.left,
223223
height: clientRect.height || clientRect.bottom - clientRect.top,
224-
}
225-
)
224+
};
225+
}
226+
227+
return {
228+
left: 0,
229+
right: 0,
230+
top: 0,
231+
bottom: 0,
232+
width: 0,
233+
height: 0,
234+
};
226235
}
227236

228237
export function getElementRect (element: Element) {

0 commit comments

Comments
 (0)