import { ref } from "vue"; /** * The card reorder gesture, shared across every NoteCard on screen. * * Module-level refs: a captured pointer sends every move to the card being dragged, * so it hit-tests for itself and publishes the result here for the other cards. * Pointer Events rather than HTML5 drag-and-drop, which never fires from touch. */ /** The card currently being dragged, or null. */ export const draggingId = ref(null); /** The card the pointer is over, if it isn't the dragged one. */ export const overId = ref(null); /** How far the pointer must travel before a press becomes a drag. */ export const DRAG_THRESHOLD_PX = 6; export function endCardDrag(): void { draggingId.value = null; overId.value = null; } /** * The id of the card under this point, ignoring `self`. * * Reads the DOM rather than tracking geometry: in a CSS masonry (`columns-*`) the * visual order isn't derivable from the model order. */ export function cardIdAt(x: number, y: number, self: string): string | null { const el = document.elementFromPoint(x, y)?.closest("[data-note-id]"); const id = el?.dataset.noteId ?? null; return id && id !== self ? id : null; }