block by shawnbot 6518285

d3 bounded zoom behavior

Full Screen

This gist shows how to restrict d3’s zoom behavior so that users can’t pan outside of a rectangular bounding box. Use your scroll wheel to zoom in and out of the field of circles, and click and drag to move when zoomed in. Note how when you zoom back out (by scrolling up) the view snaps to the original extent at zoom 1.

index.html