feat: Refactor document drag initiation and state management with new session handling and geometry utilities. (slightly broken)

This commit is contained in:
2025-11-26 00:03:59 +01:00
parent 757abe9a0f
commit 93dcde471f
8 changed files with 861 additions and 916 deletions
+35
View File
@@ -0,0 +1,35 @@
export interface CardBounds {
minX: number;
maxX: number;
minY: number;
maxY: number;
}
export interface ComputeBoundsOptions {
width: number;
height: number;
canvasWidth: number;
canvasHeight: number;
padding: number;
shelfWidth?: number;
}
export const computeCardBounds = ({
width,
height,
canvasWidth,
canvasHeight,
padding,
shelfWidth = 0,
}: ComputeBoundsOptions): CardBounds => {
const halfW = width / 2;
const halfH = height / 2;
const shelfOffset = Math.max(shelfWidth, 0);
return {
minX: padding + halfW,
maxX: Math.max(padding + halfW, canvasWidth - shelfOffset - padding - halfW),
minY: padding + halfH,
maxY: Math.max(padding + halfH, canvasHeight - padding - halfH),
};
};