All examples By author By category About


Zoom Transitions

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

function transform() {
  return d3.zoomIdentity
      .translate(width / 2, height / 2)
      .translate(-point[0], -point[1]);

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