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

fix: allow ZoomableView ref to be utilised via ZoomableViewWithGestures #95

Closed mrbrentkelly closed 6 months ago

mrbrentkelly commented 6 months ago

Fixes https://github.com/openspacelabs/react-native-zoomable-view/issues/94.

Updates the ReactNativeZoomableViewWithGestures component to manage the ref of the inner ReactNativeZoomableView component.

This allows users of ReactNativeZoomableViewWithGestures to still imperatively call the zoomTo, zoomBy, moveBy, moveTo functions of the underlying ReactNativeZoomableView.

Example:

const ref = useRef<ReactNativeZoomableViewWithGestures>(null);

return <>
  <ReactNativeZoomableViewWithGestures {ref} ... />
  <Button text="Zoom" onPress={() => {
    ref.current?.zoomableViewRef?.current?.zoomBy(2);
  }} />  
</>