// How the wheel moves a view that zooms: a pinch moves a few pixels at a time, // a mouse wheel's notch a hundred or so (or a few lines), so a notch is one // fixed step rather than a jump. const NOTCH = 1.1; /** A wheel delta in pixels, a line counting as 40. */ export function pixels(event: WheelEvent, delta: number): number { return event.deltaMode === WheelEvent.DOM_DELTA_PIXEL ? delta : delta * 40; } /** What a wheel event multiplies the zoom by. */ export function zoomFactor(event: WheelEvent): number { const moved = pixels(event, event.deltaY); return Math.abs(moved) >= 50 ? NOTCH ** -Math.sign(moved) : Math.exp(-moved * 0.01); }