Skip to content

attachAutoResize

function attachAutoResize(canvas: HTMLCanvasElement, onResizeOrOptions?:
| AutoResizeOptions
| ((width: number, height: number) => void)): () => void;

Attaches a ResizeObserver to an HTMLCanvasElement that synchronizes its internal buffer dimensions (canvas.width, canvas.height) with its rendered CSS layout size.

ParameterType
canvasHTMLCanvasElement
onResizeOrOptions?| AutoResizeOptions | ((width: number, height: number) => void)

A cleanup function to disconnect the ResizeObserver.

() => void