diff --git a/src/index.ts b/src/index.ts index 5fc60eb..45ae839 100644 --- a/src/index.ts +++ b/src/index.ts @@ -3,14 +3,15 @@ import { DimensionObject, UseDimensionsArgs, UseDimensionsHook } from "./types"; function getDimensionObject(node: HTMLElement): DimensionObject { const rect = node.getBoundingClientRect(); - + const left = "x" in rect ? rect.x : rect.left; + const top = "y" in rect ? rect.y : rect.top; return { width: rect.width, height: rect.height, - top: "x" in rect ? rect.x : rect.top, - left: "y" in rect ? rect.y : rect.left, - x: "x" in rect ? rect.x : rect.left, - y: "y" in rect ? rect.y : rect.top, + x: left, + y: top, + top: top, + left: left, right: rect.right, bottom: rect.bottom };