diff --git a/src/view/com/lightbox/ImageViewing/components/ImageItem/ImageItem.android.tsx b/src/view/com/lightbox/ImageViewing/components/ImageItem/ImageItem.android.tsx index f5e858209e..50a7645a78 100644 --- a/src/view/com/lightbox/ImageViewing/components/ImageItem/ImageItem.android.tsx +++ b/src/view/com/lightbox/ImageViewing/components/ImageItem/ImageItem.android.tsx @@ -36,8 +36,6 @@ type Props = { imageSrc: ImageSource onRequestClose: () => void onZoom: (isZoomed: boolean) => void - onLongPress: (image: ImageSource) => void - delayLongPress: number swipeToCloseEnabled?: boolean doubleTapToZoomEnabled?: boolean } @@ -48,8 +46,6 @@ const ImageItem = ({ imageSrc, onZoom, onRequestClose, - onLongPress, - delayLongPress, swipeToCloseEnabled = true, doubleTapToZoomEnabled = true, }: Props) => { @@ -72,17 +68,11 @@ const ImageItem = ({ [onZoom], ) - const onLongPressHandler = useCallback(() => { - onLongPress(imageSrc) - }, [imageSrc, onLongPress]) - const [panHandlers, scaleValue, translateValue] = usePanResponder({ initialScale: scale || 1, initialTranslate: translate || {x: 0, y: 0}, onZoom: onZoomPerformed, doubleTapToZoomEnabled, - onLongPress: onLongPressHandler, - delayLongPress, }) const imagesStyles = getImageStyles( diff --git a/src/view/com/lightbox/ImageViewing/components/ImageItem/ImageItem.ios.tsx b/src/view/com/lightbox/ImageViewing/components/ImageItem/ImageItem.ios.tsx index 03bf45af11..7a9e609a79 100644 --- a/src/view/com/lightbox/ImageViewing/components/ImageItem/ImageItem.ios.tsx +++ b/src/view/com/lightbox/ImageViewing/components/ImageItem/ImageItem.ios.tsx @@ -38,8 +38,6 @@ type Props = { imageSrc: ImageSource onRequestClose: () => void onZoom: (scaled: boolean) => void - onLongPress: (image: ImageSource) => void - delayLongPress: number swipeToCloseEnabled?: boolean doubleTapToZoomEnabled?: boolean } @@ -50,8 +48,6 @@ const ImageItem = ({ imageSrc, onZoom, onRequestClose, - onLongPress, - delayLongPress, swipeToCloseEnabled = true, doubleTapToZoomEnabled = true, }: Props) => { @@ -112,10 +108,6 @@ const ImageItem = ({ scrollValueY.setValue(offsetY) } - const onLongPressHandler = useCallback(() => { - onLongPress(imageSrc) - }, [imageSrc, onLongPress]) - return ( } diff --git a/src/view/com/lightbox/ImageViewing/components/ImageItem/ImageItem.tsx b/src/view/com/lightbox/ImageViewing/components/ImageItem/ImageItem.tsx index fd377dde2b..a74fd20238 100644 --- a/src/view/com/lightbox/ImageViewing/components/ImageItem/ImageItem.tsx +++ b/src/view/com/lightbox/ImageViewing/components/ImageItem/ImageItem.tsx @@ -8,8 +8,6 @@ type Props = { imageSrc: ImageSource onRequestClose: () => void onZoom: (scaled: boolean) => void - onLongPress: (image: ImageSource) => void - delayLongPress: number swipeToCloseEnabled?: boolean doubleTapToZoomEnabled?: boolean } diff --git a/src/view/com/lightbox/ImageViewing/hooks/usePanResponder.ts b/src/view/com/lightbox/ImageViewing/hooks/usePanResponder.ts index 7908504eab..e7c03fce18 100644 --- a/src/view/com/lightbox/ImageViewing/hooks/usePanResponder.ts +++ b/src/view/com/lightbox/ImageViewing/hooks/usePanResponder.ts @@ -27,7 +27,6 @@ import { const SCREEN = Dimensions.get('window') const SCREEN_WIDTH = SCREEN.width const SCREEN_HEIGHT = SCREEN.height -const MIN_DIMENSION = Math.min(SCREEN_WIDTH, SCREEN_HEIGHT) const ANDROID_BAR_HEIGHT = 24 const MIN_ZOOM = 2 @@ -40,8 +39,6 @@ type Props = { initialTranslate: Position onZoom: (isZoomed: boolean) => void doubleTapToZoomEnabled: boolean - onLongPress: () => void - delayLongPress: number } const usePanResponder = ({ @@ -49,8 +46,6 @@ const usePanResponder = ({ initialTranslate, onZoom, doubleTapToZoomEnabled, - onLongPress, - delayLongPress, }: Props): Readonly< [GestureResponderHandlers, Animated.Value, Animated.ValueXY] > => { @@ -62,9 +57,7 @@ const usePanResponder = ({ let tmpTranslate: Position | null = null let isDoubleTapPerformed = false let lastTapTS: number | null = null - let longPressHandlerRef: NodeJS.Timeout | null = null - const meaningfulShift = MIN_DIMENSION * 0.01 const scaleValue = new Animated.Value(initialScale) const translateValue = new Animated.ValueXY(initialTranslate) @@ -155,10 +148,6 @@ const usePanResponder = ({ return () => scaleValue.removeAllListeners() }) - const cancelLongPressHandle = () => { - longPressHandlerRef && clearTimeout(longPressHandlerRef) - } - const panResponder = PanResponder.create({ onStartShouldSetPanResponder: () => true, onStartShouldSetPanResponderCapture: () => true, @@ -173,8 +162,6 @@ const usePanResponder = ({ if (gestureState.numberActiveTouches > 1) { return } - - longPressHandlerRef = setTimeout(onLongPress, delayLongPress) }, onPanResponderStart: ( event: GestureResponderEvent, @@ -241,15 +228,8 @@ const usePanResponder = ({ event: GestureResponderEvent, gestureState: PanResponderGestureState, ) => { - const {dx, dy} = gestureState - - if (Math.abs(dx) >= meaningfulShift || Math.abs(dy) >= meaningfulShift) { - cancelLongPressHandle() - } - // Don't need to handle move because double tap in progress (was handled in onStart) if (doubleTapToZoomEnabled && isDoubleTapPerformed) { - cancelLongPressHandle() return } @@ -267,8 +247,6 @@ const usePanResponder = ({ numberInitialTouches === 2 && gestureState.numberActiveTouches === 2 if (isPinchGesture) { - cancelLongPressHandle() - const initialDistance = getDistanceBetweenTouches(initialTouches) const currentDistance = getDistanceBetweenTouches( event.nativeEvent.touches, @@ -315,7 +293,7 @@ const usePanResponder = ({ if (isTapGesture && currentScale > initialScale) { const {x, y} = currentTranslate - // eslint-disable-next-line @typescript-eslint/no-shadow + const {dx, dy} = gestureState const [topBound, leftBound, bottomBound, rightBound] = getBounds(currentScale) @@ -360,8 +338,6 @@ const usePanResponder = ({ } }, onPanResponderRelease: () => { - cancelLongPressHandle() - if (isDoubleTapPerformed) { isDoubleTapPerformed = false } diff --git a/src/view/com/lightbox/ImageViewing/index.tsx b/src/view/com/lightbox/ImageViewing/index.tsx index ec2be8b40b..16cc163b19 100644 --- a/src/view/com/lightbox/ImageViewing/index.tsx +++ b/src/view/com/lightbox/ImageViewing/index.tsx @@ -41,20 +41,17 @@ type Props = { imageIndex: number visible: boolean onRequestClose: () => void - onLongPress?: (image: ImageSource) => void onImageIndexChange?: (imageIndex: number) => void presentationStyle?: ModalProps['presentationStyle'] animationType?: ModalProps['animationType'] backgroundColor?: string swipeToCloseEnabled?: boolean doubleTapToZoomEnabled?: boolean - delayLongPress?: number HeaderComponent?: ComponentType<{imageIndex: number}> FooterComponent?: ComponentType<{imageIndex: number}> } const DEFAULT_BG_COLOR = '#000' -const DEFAULT_DELAY_LONG_PRESS = 800 const SCREEN = Dimensions.get('screen') const SCREEN_WIDTH = SCREEN.width @@ -64,12 +61,10 @@ function ImageViewing({ imageIndex, visible, onRequestClose, - onLongPress = () => {}, onImageIndexChange, backgroundColor = DEFAULT_BG_COLOR, swipeToCloseEnabled, doubleTapToZoomEnabled, - delayLongPress = DEFAULT_DELAY_LONG_PRESS, HeaderComponent, FooterComponent, }: Props) { @@ -148,8 +143,6 @@ function ImageViewing({ onZoom={onZoom} imageSrc={imageSrc} onRequestClose={onRequestCloseEnhanced} - onLongPress={onLongPress} - delayLongPress={delayLongPress} swipeToCloseEnabled={swipeToCloseEnabled} doubleTapToZoomEnabled={doubleTapToZoomEnabled} />