Skip to content

Instantly share code, notes, and snippets.

@garrilla
garrilla / README.md
Last active February 11, 2016 07:47 — forked from mbostock/.block
Zoom + Pan with Limiting

This is an example of pan limiting, trapping for zoom.translate() by passing an array, which is determined by a simple boolean network for each of x and y of the translation to ensure that dragging is constrained within the panExtent.

It is a fork of Pan+Zoom demonstrating an example of d3.behavior.zoom applied using x- and y-scales.

Requirements

  1. create an object variable var panExtent = {x: [0,600], y: [-200,Infinity] }; to set the limits of the pan

  2. when setting the domain test for compliance with the panExtent (the domain should be no bigger than panExtent)