Skip to content

Latest commit

 

History

History
 
 

interpolate-zoom

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Interpolate Zoom

As of D3 3.3, the zoom interpolator is now part of D3 core and this plugin is deprecated.

An interpolator for zooming and panning between two views of a two-dimensional plane, based on “Smooth and efficient zooming and panning” by Jarke J. van Wijk and Wim A.A. Nuij.

Demo: http://bl.ocks.org/3828981

To use this plugin:

<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<script src="http://d3js.org/d3.interpolate-zoom.v0.min.js" charset="utf-8"></script>

Note that since this script uses UTF-8 characters, the charset attribute is required if the page does not have a <meta charset="utf-8"> in the head. There’s also a d3.interpolate-zoom.v0.js for development, or you can clone this repository.

# d3.interpolateZoom(start, end)

Returns an interpolator between the two points start and end. Each point should be defined as an array of three numbers in world coordinates: ux, uy and w. The first two coordinates ux, uy are the center of the viewport. The last coordinate w is the size of the viewport.

The returned interpolator also has a duration property which encodes the recommended transition duration in milliseconds. This duration is based on the path length of the curved trajectory through u,w space. If you want to a slower or faster transition, feel free to multiply this by an arbitrary scale factor (V as described in the original paper).