@mocanvas/editor · function

usePassThroughWheelEvents

declare function usePassThroughWheelEvents(ref: RefObject<HTMLElement | null>): void

Let a wheel event over this element reach the canvas underneath it.

A scrollable panel over the canvas swallows the wheel, so zooming with the pointer over a toolbar does nothing — which reads as the editor being broken. This re-dispatches the event on the element behind the panel, and suppresses the browser's own scrolling of the page.

The listener is registered non-passively on purpose: a passive wheel listener may not call preventDefault, and suppressing the page scroll is half the point.

mocanvas is built by Symbio. Free for non-commercial, non-profit and development use; commercial use needs an agreement. Not affiliated with or endorsed by tldraw.