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
212 stars 58 forks source link

Zoomable ScrollView #29

Open oofavor opened 2 years ago

oofavor commented 2 years ago

Is there any way to use ReactNativeZoomableView with ScrollView and/or FlatList?

mazenchami commented 2 years ago

+1

Huailun commented 2 years ago

I was able to use ReactNativeZoomableView with FlatList in renderItem without any problem.

andhikanovandi commented 2 years ago

@Huailun hi there, do you mind to share some example code for that? thanks!

putuoka commented 2 years ago

i think i need this too for react native pager view https://github.com/callstack/react-native-pager-view looks like they using flatlist. currenty zoomable view isn't working with it. i use this lib to replace https://github.com/intergalacticspacehighway/react-native-reanimated-zoom working very good pinch zoom, pan, and double tap zoom

asterginete commented 1 year ago

I was able to use ReactNativeZoomableView with ScrollView Refer to this old comment

  const zoomableViewRef = useRef(null);
  const scrollViewRef = useRef(null);
  const [scrollEnabled, setScrollEnabled] = useState(true);

  const execAfterZoom = () =>
    scrollViewRef &&
    zoomableViewRef &&
    setScrollEnabled(zoomableViewRef.current?.zoomLevel < 1.01);

  const yourComponent = (
    <ScrollView scrollEnabled={scrollEnabled}>
      <ReactNativeZoomableView
        ref={zoomableViewRef}
        onZoomAfter={execAfterZoom}
        onShiftingEnd={execAfterZoom}
        disablePanOnInitialZoom={true}>
        <Text>Zoomable Text</Text>
      </ReactNativeZoomableView>
    </ScrollView>
  );

Toggle the ScrollView's scrollEnabled prop on onZoomAfter and onShiftingEnd callbacks of the ReactNativeZoomableView so that the scrolling won't conflict with the zoomable view's panresponders.

budwol commented 1 year ago

i got issue in flatlist - swiping is not working when zoomableview is used as child.

ywanhzy commented 6 months ago

I have a problem. scrolllview cannot slide normally when multiple ReactNativeZoomableViews are called in ScrollView. Is there any way to solve this problem? please help me @thomasttvo

NxsHbb commented 4 weeks ago

I was able to use ReactNativeZoomableView with ScrollView Refer to this old comment

  const zoomableViewRef = useRef(null);
  const scrollViewRef = useRef(null);
  const [scrollEnabled, setScrollEnabled] = useState(true);

  const execAfterZoom = () =>
    scrollViewRef &&
    zoomableViewRef &&
    setScrollEnabled(zoomableViewRef.current?.zoomLevel < 1.01);

  const yourComponent = (
    <ScrollView scrollEnabled={scrollEnabled}>
      <ReactNativeZoomableView
        ref={zoomableViewRef}
        onZoomAfter={execAfterZoom}
        onShiftingEnd={execAfterZoom}
        disablePanOnInitialZoom={true}>
        <Text>Zoomable Text</Text>
      </ReactNativeZoomableView>
    </ScrollView>
  );

Toggle the ScrollView's scrollEnabled prop on onZoomAfter and onShiftingEnd callbacks of the ReactNativeZoomableView so that the scrolling won't conflict with the zoomable view's panresponders.

I am using it in expo SDK 50 managed project. It works on development build, but in production build it does not work. Any idea?