feat(input): add DOM event command adapters
This commit is contained in:
19
input/viewport.ts
Normal file
19
input/viewport.ts
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user