diff --git a/packages/website/src/components/MainSection/EditorSection/DragHandle.tsx b/packages/website/src/components/MainSection/EditorSection/DragHandle.tsx index f510994..920d378 100644 --- a/packages/website/src/components/MainSection/EditorSection/DragHandle.tsx +++ b/packages/website/src/components/MainSection/EditorSection/DragHandle.tsx @@ -1,7 +1,7 @@ import { createEffect, createSignal, onCleanup, onMount, Show, type ComponentProps } from "solid-js"; -import IconDragHandleY from "~icons/fluent/re-order-dots-horizontal-24-filled"; -import IconDragHandleX from "~icons/fluent/re-order-dots-vertical-24-filled"; +import IconDragHandleHeight from "~icons/fluent/re-order-dots-horizontal-24-filled"; +import IconDragHandleWidth from "~icons/fluent/re-order-dots-vertical-24-filled"; import { debounce } from "@bundlejs/core"; @@ -64,15 +64,15 @@ export function DragHandle(props?: ComponentProps<'button'> & { createEffect(() => { targetEl?.style?.removeProperty?.(sizeProp()); - console.log(dirIsX()) setDirIsX(props?.direction == "x"); setSizeProp(dirIsX() ? "width" : "height"); setMouseDir(dirIsX() ? "clientX" : "clientY"); setCursorProp(dirIsX() ? "col-resize" : "row-resize"); + console.count(sizeProp()) - if (props?.contrain) { + if (props?.contrain && !observer) { observer = new ResizeObserver( debounce(() => { parentSize = parentEl.getBoundingClientRect()[sizeProp()]; @@ -88,6 +88,7 @@ export function DragHandle(props?: ComponentProps<'button'> & { if (props?.contrain) { observer?.unobserve?.(parentEl); observer?.disconnect?.(); + observer = null; } }); @@ -110,8 +111,9 @@ export function DragHandle(props?: ComponentProps<'button'> & { return ( ); } diff --git a/packages/website/src/components/MainSection/EditorSection/EditorSection.tsx b/packages/website/src/components/MainSection/EditorSection/EditorSection.tsx index 4f0299f..e7a89ae 100644 --- a/packages/website/src/components/MainSection/EditorSection/EditorSection.tsx +++ b/packages/website/src/components/MainSection/EditorSection/EditorSection.tsx @@ -11,7 +11,7 @@ import Tabs from "./Tabs"; const [direction, setDirection] = createSignal<"x" | "y">("x"); function onResize(e: MediaQueryListEvent | MediaQueryList) { - e && setDirection(e.matches ? 'x' : 'y'); + setDirection(e.matches ? 'x' : 'y'); } let mediaQuery = ("document" in globalThis) && globalThis?.matchMedia?.("(min-width: 640px)"); @@ -19,8 +19,6 @@ onResize(mediaQuery); export function EditorSection(props?: ComponentProps<'div'>) { onMount(() => { - // mediaQuery = globalThis?.matchMedia?.("(min-width: 640px)"); - // onResize(mediaQuery); mediaQuery?.addEventListener?.("change", onResize); });