refactor(web): centralize touch mouse adapters
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user