Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Example UsageArgumentsReturn Value
var zoomer = zs.createZoomer(opts);

opts - an object containing:

svg: <d3 selection of svg element>

zoomLayer: <d3 selection of g element, child of svg element>

zoomEnabled: (optional) function reference that returns truthy values when zoom should be enabled and falsy values otherwise

zoomCallback: (optional) function reference to be called when the layer is zoomed

an object containing an API, see below
Returned API Example UsageArgumentsReturn Value
zoomer.panZoom(translate, scale);

translate - an array which is the zoom translation vector that you want to translate to

scale - a Number which is the scale that you want to zoom in to

none, but the view will be zoomed
zoomer.reset();nonenone, but resets the pan and zoom levels back to default
zoomer.translate();nonethe current translation vector
zoomer.scale();nonethe current zoom scale
zoomer.scaleExtent();nonethe current zoom scale's range