feat(input): add DOM event command adapters

This commit is contained in:
syntaxbullet
2026-07-03 09:37:25 +02:00
parent 91436086a8
commit dd1b892034
3 changed files with 67 additions and 0 deletions

19
input/viewport.ts Normal file
View File

@@ -0,0 +1,19 @@
import type { Dispatch } from "@commands/dispatcher";
import type { GlobalWheelConsumer, WheelInputEvent } from "./pointer";
export function handleViewportWheel(options: {
event: WheelInputEvent;
globalConsumer: GlobalWheelConsumer;
dispatch: Dispatch;
currentZoom: number;
}): boolean {
if (options.globalConsumer(options.event)) return true;
const zoomFactor = Math.exp(-options.event.delta.y * 0.001);
options.dispatch("viewport.zoomAroundPoint", {
zoom: options.currentZoom * zoomFactor,
point: options.event.position,
});
return true;
}