diff --git a/lib/folk-shape.ts b/lib/folk-shape.ts index 425433d..5c79c8c 100644 --- a/lib/folk-shape.ts +++ b/lib/folk-shape.ts @@ -318,10 +318,14 @@ export class FolkShape extends FolkElement { handle = focusedElement.getAttribute("part") as Handle | null; } + // Check if target is a drag handle (header or element with data-drag attribute) + const isDragHandle = target?.closest?.(".header, [data-drag]") !== null; + if (event instanceof PointerEvent) { event.stopPropagation(); if (event.type === "pointerdown") { - if (target !== this && !handle) return; + // Allow drag from: the host itself, a handle, or a drag handle element + if (target !== this && !handle && !isDragHandle) return; if (handle?.startsWith("rotation")) { const parentRotateOrigin = this.#rect.toParentSpace({ @@ -373,7 +377,7 @@ export class FolkShape extends FolkElement { if (!moveDelta) return; - if (target === this || (!handle && event instanceof KeyboardEvent)) { + if (target === this || isDragHandle || (!handle && event instanceof KeyboardEvent)) { if (event instanceof KeyboardEvent && event.altKey) { const ROTATION_MUL = event.shiftKey ? Math.PI / 12 : Math.PI / 36; const rotationDelta = moveDelta.x !== 0 ? (moveDelta.x > 0 ? ROTATION_MUL : -ROTATION_MUL) : 0;