mirror of
https://github.com/webstudio-is/webstudio.git
synced 2026-11-09 05:26:24 +09:00
create probe lazily because of SSR
This commit is contained in:
1 parent
afa5139b6e
commit
2a8a8635de
1 file changed
+8
-1
@@ -4,7 +4,13 @@ import { Box } from "../../box";
|
||||
export type Rect = Pick<DOMRect, "top" | "left" | "width" | "height">;
|
||||
type Point = { x: number; y: number };
|
||||
|
||||
const probe = document.createElement("div");
|
||||
let probeCache: undefined | HTMLElement;
|
||||
const getProbe = () => {
|
||||
if (probeCache === undefined) {
|
||||
probeCache = document.createElement("div");
|
||||
}
|
||||
return probeCache;
|
||||
};
|
||||
|
||||
/**
|
||||
* We place a div at the position where future drop will happen.
|
||||
@@ -17,6 +23,7 @@ const getPlacement = ({
|
||||
target: HTMLElement;
|
||||
index?: number;
|
||||
}) => {
|
||||
const probe = getProbe();
|
||||
const { children } = target;
|
||||
if (index > children.length - 1) {
|
||||
target.appendChild(probe);
|
||||
|
||||
Reference in new issue
Block a user