d3 / d3-zoom

Pan and zoom SVG, HTML or Canvas using mouse or touch input.
https://d3js.org/d3-zoom
ISC License
502 stars 143 forks source link

zoom.scaleBy, scaleTo and translateTo should support a reference point. #178

Closed mbostock closed 4 years ago

mbostock commented 5 years ago

Currently these functions all use the viewport centroid as the reference point, but it would be nice to be able to specify the point explicitly.

mbostock commented 5 years ago

For example, in Zoomable Map Tiles, it would be great if double-clicking zoomed to the nearest power of two. But doing this requires overriding the dblclick.zoom listener to replace the default behavior, and it’s difficult to implement the desired behavior on top of zoom.scaleTo because that only zooms around the viewport’s centroid rather than the mouse location.