Skip to content

Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.

move the cached getComputedStyle and getBoundingClientRect back into where its used

Oleg Isonen69140cb32362
diff --git a/app/canvas/shared/use-drag-drop-handlers.ts b/app/canvas/shared/use-drag-drop-handlers.ts
index e12e8d75e0..4ed7b79127 100644
--- a/app/canvas/shared/use-drag-drop-handlers.ts
+++ b/app/canvas/shared/use-drag-drop-handlers.ts
@@ -5,14 +5,21 @@ import { findInstanceById } from "~/shared/tree-utils";
import {
findClosestChild,
findInsertionIndex,
- getBoundingClientRect,
- getComputedStyle,
getDragOverInfo,
} from "~/shared/dom-utils";
import { useDropData, useSelectedInstance } from "./nano-states";
import { useRootInstance } from "~/shared/nano-states";
+import memoize from "lodash.memoize";
//import {usePointerOutline} from './use-pointer-outline'
+const getBoundingClientRect = memoize((element: Element | HTMLElement) =>
+ element.getBoundingClientRect()
+);
+
+const getComputedStyle = memoize((element: Element | HTMLElement) =>
+ window.getComputedStyle(element)
+);
+
export const useDragDropHandlers = () => {
const [rootInstance] = useRootInstance();
const [, setSelectedInstance] = useSelectedInstance();
diff --git a/app/shared/dom-utils/get-bounding-client-rect.ts b/app/shared/dom-utils/get-bounding-client-rect.ts
deleted file mode 100644
index 71ca8c47bd..0000000000
--- a/app/shared/dom-utils/get-bounding-client-rect.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-import memoize from "lodash.memoize";
-
-// For example used to avoid recalculating rects for each node during dragging.
-export const getBoundingClientRect = memoize((element: Element | HTMLElement) =>
- element.getBoundingClientRect()
-);
diff --git a/app/shared/dom-utils/get-computed-style.ts b/app/shared/dom-utils/get-computed-style.ts
deleted file mode 100644
index af9a6160b1..0000000000
--- a/app/shared/dom-utils/get-computed-style.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-import memoize from "lodash.memoize";
-
-// For example used to avoid recalculating rects for each node during dragging.
-export const getComputedStyle = memoize((element: Element | HTMLElement) =>
- window.getComputedStyle(element)
-);
diff --git a/app/shared/dom-utils/index.ts b/app/shared/dom-utils/index.ts
index 6708cd1f9c..e4b75bccde 100644
--- a/app/shared/dom-utils/index.ts
+++ b/app/shared/dom-utils/index.ts
@@ -1,5 +1,3 @@
export * from "./find-closest-child";
export * from "./find-insertion-index";
export * from "./get-drag-over-info";
-export * from "./get-bounding-client-rect";
-export * from "./get-computed-style";