openspacelabs / react-native-zoomable-view

A view component for react-native with pinch to zoom, tap to move and double tap to zoom capability.
MIT License
205 stars 57 forks source link

Incorrect zoom center #54

Open maxkemzi opened 1 year ago

maxkemzi commented 1 year ago

When using the zoomTo method or double-tapping with doubleTapZoomToCenter prop set to true, the ZoomableView zooms to the upper left corner instead of the center of the View. Because of this, the animation is jumping during the resetting of the zoom level if the bindToBorders prop is set to true.

react: 18.1.0 react-native: 0.70.5 @openspacelabs/react-native-zoomable-view: 2.1.1

Video: https://user-images.githubusercontent.com/70598945/209668428-447dcd04-4bb6-4428-9aeb-e4b8bbd9bdc3.mp4

nicholas-patterson commented 1 year ago

Also having the same issue.

DLkhazan commented 1 year ago

Having the same issue, did you find anything useful? @nicholas-patterson @Kemzi-coder

DLkhazan commented 1 year ago

@thomasttvo can you provide any input on this?

20chad16 commented 1 year ago

I am running into this issue when having two zoomable views side-by-side. Has anyone found a solution or workaround?

@thomasttvo

DLkhazan commented 1 year ago

@20chad16 you need to disable panning from the node_module.

belalNabhani commented 1 year ago

@DLkhazan Can you elaborate? I'm running at the issue, and I'm not an expert with animation.

DLkhazan commented 1 year ago

@c00ler82 I can provide you the file. Navigate to APP_FOLDER/node_modules/@openspacelabs/react-native-zoomable-view/src/ReactNativeZoomableView.tsx. And replace it with the attached file.

I made multiple changes to the file but I think the one you required will be achieved by modifying _handleShifting function. You can compare the library and modified function from the file. had to compress it, because they won't let me post it in original formate. But let me know if you need my help to understand it. zoomableview.zip

belalNabhani commented 1 year ago

Yeah probably _handleShifting what I was missing. Thank you @DLkhazan. Worked like a charm.