Skip to main content

Home > blockly > WorkspaceSvg > zoom

WorkspaceSvg.zoom() method

Zooms the workspace in or out relative to/centered on the given (x, y) coordinate.

Signature:

zoom(x: number, y: number, amount: number): void;

Parameters

ParameterTypeDescription
xnumberX coordinate of center, in pixel units relative to the top-left corner of the parentSVG.
ynumberY coordinate of center, in pixel units relative to the top-left corner of the parentSVG.
amountnumberAmount of zooming. The formula for the new scale is newScale = currentScale * (scaleSpeed^amount). scaleSpeed is set in the workspace options. Negative amount values zoom out, and positive amount values zoom in.

Returns:

void