All examples By author By category About

domhorvath

Zoom Transitions

This example demonstrates smooth zoom transitions using d3-zoom. Every 2.5 seconds, a circle is randomly selected, and the transform to position the circle at the center of the viewport is computed as follows:

function transform() {
  return d3.zoomTransform()
      .translate(width / 2, height / 2)
      .scale(8)
      .translate(-circle.x, -circle.y);
}

Then, transition.call is used to invoke zoom.transform with the new transform, initiating a smooth zoom transition from the current transform.

forked from mbostock's block: Zoom Transitions