From acded14e163e97426b9fb68b823951ff54d6c964 Mon Sep 17 00:00:00 2001 From: Andrey Lobanov Date: Tue, 29 Nov 2022 22:58:06 +0400 Subject: [PATCH] Fixed issues/934 - added required Rect with zeros --- packages/@interactjs/utils/domUtils.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/packages/@interactjs/utils/domUtils.ts b/packages/@interactjs/utils/domUtils.ts index 76f685e33..92550c135 100644 --- a/packages/@interactjs/utils/domUtils.ts +++ b/packages/@interactjs/utils/domUtils.ts @@ -213,8 +213,8 @@ export function getElementClientRect (element: Element): Required { 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, @@ -222,7 +222,16 @@ export function getElementClientRect (element: Element): Required { 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) {