Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to work with react-native-pager-view #90

Open
lovetingyuan opened this issue Mar 15, 2024 · 4 comments
Open

how to work with react-native-pager-view #90

lovetingyuan opened this issue Mar 15, 2024 · 4 comments

Comments

@lovetingyuan
Copy link

lovetingyuan commented Mar 15, 2024

I think the user gesture conflicts between [react-native-zoomable-view] and react-native-pager-view

@davide-granello
Copy link

I'm also trying to implement a sliding carousel with zoomable images, using this library in combination of this: https://reanimated-carousel.dev/

Disabling the pan in react-native-zoomable-view and a few other tricks, i managed to make it work

@akira-0924
Copy link

@lovetingyuan
I also used react-native-zoomable-view and react-native-pager-view together and faced exactly the same problem. In my case, I wanted to be able to swipe if the zommLevel was 1 and adapt the zoom-view panning otherwise, so I solved this by using onShouldBlockNativeResponder Hooks.

import { ReactNativeZoomableView, ZoomableViewEvent } from '@openspacelabs/react-native-zoomable-view';
import { GestureResponderEvent, PanResponderGestureState } from 'react-native';


const onShouldBlockNativeResponderHandler = (
    event: GestureResponderEvent,
    gestureState: PanResponderGestureState,
    zoomableViewEventObject: ZoomableViewEvent
  ): boolean => {
    if (zoomableViewEventObject.zoomLevel === 1) {
      return false;
    } else {
      return true;
    }
  };

return (
    <ReactNativeZoomableView
      maxZoom={2.4}
      disablePanOnInitialZoom={true}
      onShouldBlockNativeResponder={onShouldBlockNativeResponderHandler}
    >
      <Image
        source={}
      />
    </ReactNativeZoomableView>

@cveklica
Copy link

cveklica commented Jun 7, 2024

Thanks for this @akira-0924, but this disables doubleTap zoom when zoomLevel is 1. Any solutions?
I tried doing custom zoomTo on event onDoubleTapBefore but still blocked. onDoubleTapAfter and zoomTo gives bad behaviour.

@emreer94
Copy link

Thank you @akira-0924 <3 this works quite well. Also, it works in doubleTap zoom as well @cveklica I tried that as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants