msand / zoomable-svg

Pinch to pan-n-zoom react-native-svg components using a render prop.
38 stars 14 forks source link

Example: How to set zoom focus point? #3

Open egunsoma opened 6 years ago

egunsoma commented 6 years ago

When running on Android Emulator, the focus point of the zoom is not in the middle, but on the left side of the screen. Any ideas why? :) I can post screenshots, but the code is the same as in the example.

msand commented 6 years ago

I'm not sure what you mean, perhaps the screenshots would help 😉

salacode commented 4 years ago

I suspect the problem was that if zoomable-svg is not placed to the top-left corner of the screen then the zoom focus/origin/center point is not properly calcualted. Simply, when pinching, the objects are sliping away a bit.

I think the problem is that zoomable-svg does not translate absolute (pageX, pageY) coords into relative ones. I have a fix, @msand do you accept PR-s? Here is my propsed fix: https://github.com/msand/zoomable-svg/compare/master...salacode:master