svg.panzoom.js
svg.panzoom.js copied to clipboard
Update basic demo to include viewbox
Great library! One suggestion for the README file.
Please include examples that setup up the viewbox. I spent about an hour trying to figure out why the most basic examples wouldn't integrate with my existing svgdotjs code. Turns out I wasn't setting the viewbox and I wouldn't have known to do this unless I dug into the issues on this repo.
A basic example might be:
// enables panZoom
var canvas = SVG()
.addTo('#id')
.size(1000, 1000)
.viewbox('0 0 500 500')
.panZoom()
// zoom programatically
canvas.zoom(lvl, point)
I understand that this will setup a 1000x1000 canvas and create 500x500 viewbox.
If you don't do something like this then one gets console errors like:
Error: <svg> attribute viewBox: Expected number...
Thank you!
Feel free to go ahead and create a pr which adds that to the Readme :)
Thank you! This is really helpful.
me too
Super helpful, thank you @sdiemert!