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

the call back onShiftingBefore cannot interrupt all movement #45

Closed hungtooc closed 10 months ago

hungtooc commented 1 year ago

I'm trying to prevent user move the image by one finger, allow user move by two (using zoom event). Here í my code:

const onshiftingbefore = () => {
    return true;
  };
<ReactNativeZoomableView
  maxZoom={30}
  minZoom={0.9}
  panBoundaryPadding={300}
  // movementSensibility={1}
  ref={zoomableViewRef}
  // contentWidth={300}
  // contentHeight={200}
  bindToBorders={true}

  onShiftingEnd={onShiftEnd}
  onShiftingAfter={onshiftingafter}
  onShiftingBefore={onshiftingbefore}
  onTouchStart={ontouchStart}
  onTouchMove={_onTouchMove}
  onTouchCancel={_onTouchCancel}
  onLongPress={_onLongPress}
  // onTransform = {_onTransform}
  onTouchEnd={ontouchEnd}
>
  <Image
    ref={image}
    style={{ width: "100%", height: "100%", resizeMode: "contain" }}
    source={{ uri: "https://picsum.photos/200/300" }}
  />
</ReactNativeZoomableView>

the result is: https://user-images.githubusercontent.com/24487114/197664219-52f8ffa4-e3f9-4c4a-83f1-4996a8bd5aa2.mp4