Svg pan zoom

This is a demo of my JS PanZoom code for autoscaled SVGs. See the github repo for the code and an explanation of how to use it yourself. I made it for a previous version of this website.

I recently looked into polishing this code a bit and wrapping this code into a module and publishing it on npm. However, I noticed npm already has a couple of good packages available, so I don't think I will spent time on this anymore.


  • Simple and short code, very easy to use
  • Some simple configuration options (eg zoom speed)
  • Works on all modern browsers (Chrome, IE11, Firefox, mobile browsers as well)
  • Supports mouse and touch events, including pinch to zoom
  • Works with autoscaled SVGs, even when size of SVG is changing
  • No dependencies
  • Code can be embedded in SVG or loaded elsewhere in the DOM