refactor(web): centralize touch mouse adapters

This commit is contained in:
2026-04-01 10:43:38 +02:00
parent eda8722d83
commit 0ab1374853
5 changed files with 82 additions and 30 deletions
+23
View File
@@ -9,6 +9,15 @@ export type TouchDecisionState = {
decided: boolean;
};
export type TouchMouseDownEvent = {
button: number;
clientX: number;
currentTarget?: EventTarget | null;
shiftKey: boolean;
preventDefault: () => void;
stopPropagation: () => void;
};
type TouchLike = {
clientX: number;
clientY: number;
@@ -27,6 +36,20 @@ export function getTouchPoint(event: TouchEventLike): TouchPoint {
};
}
export function createTouchMouseDownEvent(
point: TouchPoint,
currentTarget?: EventTarget | null,
): TouchMouseDownEvent {
return {
button: 0,
clientX: point.clientX,
currentTarget: currentTarget ?? null,
shiftKey: false,
preventDefault: () => {},
stopPropagation: () => {},
};
}
export function resolveTouchDragDecision(
state: TouchDecisionState,
point: TouchPoint,