mbostock/d3 — pull request #488 by mbostock (2012-02-03 01:52:38+00:00)
Title: Rewrite of d3.behavior.zoom.

The extent functionality is simplified, such that the zoom behavior only
supports an extent on the scale factor. Furthermore, the extent is expressed as
a scale factor rather than a zoom level, for consistency. An extent on translate
is no longer supported; this isn't possible unless the zoom behavior also knows
the size of the canvas.

The scale transform functionality is also simplified; simply register an x or y
scale, and the zoom behavior will automatically update the domain before a zoom
event is dispatched. If you change the scale's domain programmatically, you can
simply reassign the scale to the zoom behavior.

Both of these changes are strictly backwards-incompatible. However, since this
class is undocumented, I'll probably let this slide with a minor version bump
rather than waiting until v3.

This commit also reduces the scroll speed slightly, since the previous
implementation seemed a little too fast for my liking. It would be easy to make
the scroll speed configurable as a future enhancement.

Implementation note: rather than using global event listeners on the window, and
needing to copy local state into globals on interaction start, the zoom behavior
now uses closures that are temporarily bound (e.g., mousemove and mouseup are
bound on mousedown, and removed on mouseup).

Fixes #484, allowing scale and translate to be get or set externally.
Fixes #485, providing an example of integration with d3.geo.projection.
Fixes #487, using a scale extent rather than a zoom-level extent.