Closed rupl closed 7 years ago
I had a thought and wanted to jot it down for later. The answer is within these three objects I think:
getBBox()
returns SVGRect
— describing where the scene is positioned inside the SVGgetBoundingClientRect()
returns ClientRect
— describing where the scene is positioned within the user's viewportscene_transform
holds values that let me translate between these two rectangles. User can drag or pinch to change the scene_transform
.Currently scene_transform
does NOT alter the SVGRect
when I update these values, but it might be the way to properly calculate the math since SVGRect
is bound to the SVG instead of the user view... its effective scale
is always 1, so calculating distances at SVGRect
in relation to Hammer's ev.center
values might yield the right transform.
I almost can't believe it, but I finally got this right! 10 months... :bowtie:
@afragon this is another one that could use some thrashing to try and break it. Once it's in, I'm gonna start the code cleanup and that will be messy so I want these new features to have some eyes so I don't have to bugfix while I'm re-organizing code.
I can't take it any longer! I have to deploy this!
This is an unsolved mystery leftover from #24, #32, and other issues. The center of the zoom should always be the center of the pinch. Hammer gives us the "center" of any gestures it registers, so working out the math to zoom correctly is (as it always has been) the main blocker to getting this right.