SVG viewBox zoom in center (Raphael)

user1085803 picture user1085803 · Dec 7, 2011 · Viewed 10.4k times · Source

I try to zoom with mousewheel on a Raphael paper using viewBox. Here is the JSFiddle code.

it works but now i want to zoom in the center and i have no idea where to start. I guess i should change the viewBox x and y coordinates. I have tried this (in the function handle(delta)):

x = paper.width - viewBoxWidth;
y = paper.height - viewBoxHeight;
paper.setViewBox(x,y,viewBoxWidth,viewBoxHeight);

but didnt work. I would appreciate any help. Thank you!

Answer

Elbert Alias picture Elbert Alias · Dec 11, 2011

Since your question has been answered on the mailing list I'll paste this here for future reference:

https://groups.google.com/forum/#!topic/raphaeljs/K-84cOe8ZP8