I have a problem with my canvas.
My canvas in first width = 1300, height = 500
Then I resize it to width = 800px, height = 500
I try setViewBox to zoom it. But mouse not fix with element when I drag them.
@canvas.resize(800, 500)
@canvas.setViewBox(0,0, ??, ??)
how to calculate it???
Thank for your help. :)
You can calculate the necessary dimensions using an approach like this:
Essentially, you simply walk the contents of the canvas and construct a meta-bounding box, then adjust the viewBox to it.
If you wanted to get a little fancy, you could always animate the viewbox so that it transitions fluidly to it's new size. Not functionally important, but moderately sexy...