block by mbostock a980aba1197350ff2d5a5d0f5244d8d1

Pan & Zoom V

Full Screen

This example demonstrates how to fixate d3-zoom on a point of interest: zooming using the wheel or touch is allowed, but panning is not. When a zoom event is emitted, the current transform is translated to put the focus point at the center of the viewport:

var point = transform.invert(center);
transform = transform.translate(point[0] - focus[0], point[1] - focus[1]);

Compare this to non-fixated zooming.