I have to create a zoom feature in my application. Zooming listens really easy but I have really big trouble with it.
Okay, I have my page (orange) and on this page is a div (blue). In this div is an SVG with a group (gray). This group has an offset with a transform matrix. e.g.
<g transform="matrix(1,0,0,1,-188,-101)"><!-- [...] --></g>
You can drag and drop elements and you can also move the group. Now, i want to add a zoom feature. I realize this by change the matrix. e.g. matrix(2,0,0,2,-188,-101) is to double the scale.
If I only scale the group, my current elements are out of my viewpoint. I have to change the offset to get them back to the viewpoint.
My first idea was to multiply the offset with 2. But this cannot work. So, I thought a bit about this topic. My next idea was to get the mouse Point and the distance to the middle point of the group. And then scale this distance by my scaling factor. But this also doesn't work. I have no ideas anymore how I can solve this issue. I can also get all heights and width of all elements.