Always enable double tap
This commit is contained in:
@@ -37,7 +37,6 @@ type Props = {
|
|||||||
onRequestClose: () => void
|
onRequestClose: () => void
|
||||||
onZoom: (isZoomed: boolean) => void
|
onZoom: (isZoomed: boolean) => void
|
||||||
swipeToCloseEnabled?: boolean
|
swipeToCloseEnabled?: boolean
|
||||||
doubleTapToZoomEnabled?: boolean
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const AnimatedImage = Animated.createAnimatedComponent(Image)
|
const AnimatedImage = Animated.createAnimatedComponent(Image)
|
||||||
@@ -47,7 +46,6 @@ const ImageItem = ({
|
|||||||
onZoom,
|
onZoom,
|
||||||
onRequestClose,
|
onRequestClose,
|
||||||
swipeToCloseEnabled = true,
|
swipeToCloseEnabled = true,
|
||||||
doubleTapToZoomEnabled = true,
|
|
||||||
}: Props) => {
|
}: Props) => {
|
||||||
const imageContainer = useRef<ScrollView & NativeMethodsMixin>(null)
|
const imageContainer = useRef<ScrollView & NativeMethodsMixin>(null)
|
||||||
const imageDimensions = useImageDimensions(imageSrc)
|
const imageDimensions = useImageDimensions(imageSrc)
|
||||||
@@ -72,7 +70,6 @@ const ImageItem = ({
|
|||||||
initialScale: scale || 1,
|
initialScale: scale || 1,
|
||||||
initialTranslate: translate || {x: 0, y: 0},
|
initialTranslate: translate || {x: 0, y: 0},
|
||||||
onZoom: onZoomPerformed,
|
onZoom: onZoomPerformed,
|
||||||
doubleTapToZoomEnabled,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
const imagesStyles = getImageStyles(
|
const imagesStyles = getImageStyles(
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ type Props = {
|
|||||||
onRequestClose: () => void
|
onRequestClose: () => void
|
||||||
onZoom: (scaled: boolean) => void
|
onZoom: (scaled: boolean) => void
|
||||||
swipeToCloseEnabled?: boolean
|
swipeToCloseEnabled?: boolean
|
||||||
doubleTapToZoomEnabled?: boolean
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const AnimatedImage = Animated.createAnimatedComponent(Image)
|
const AnimatedImage = Animated.createAnimatedComponent(Image)
|
||||||
@@ -49,7 +48,6 @@ const ImageItem = ({
|
|||||||
onZoom,
|
onZoom,
|
||||||
onRequestClose,
|
onRequestClose,
|
||||||
swipeToCloseEnabled = true,
|
swipeToCloseEnabled = true,
|
||||||
doubleTapToZoomEnabled = true,
|
|
||||||
}: Props) => {
|
}: Props) => {
|
||||||
const scrollViewRef = useRef<ScrollView>(null)
|
const scrollViewRef = useRef<ScrollView>(null)
|
||||||
const [loaded, setLoaded] = useState(false)
|
const [loaded, setLoaded] = useState(false)
|
||||||
@@ -126,7 +124,7 @@ const ImageItem = ({
|
|||||||
})}>
|
})}>
|
||||||
{(!loaded || !imageDimensions) && <ImageLoading />}
|
{(!loaded || !imageDimensions) && <ImageLoading />}
|
||||||
<TouchableWithoutFeedback
|
<TouchableWithoutFeedback
|
||||||
onPress={doubleTapToZoomEnabled ? handleDoubleTap : undefined}
|
onPress={handleDoubleTap}
|
||||||
accessibilityRole="image"
|
accessibilityRole="image"
|
||||||
accessibilityLabel={imageSrc.alt}
|
accessibilityLabel={imageSrc.alt}
|
||||||
accessibilityHint="">
|
accessibilityHint="">
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ type Props = {
|
|||||||
onRequestClose: () => void
|
onRequestClose: () => void
|
||||||
onZoom: (scaled: boolean) => void
|
onZoom: (scaled: boolean) => void
|
||||||
swipeToCloseEnabled?: boolean
|
swipeToCloseEnabled?: boolean
|
||||||
doubleTapToZoomEnabled?: boolean
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const ImageItem = (_props: Props) => {
|
const ImageItem = (_props: Props) => {
|
||||||
|
|||||||
@@ -38,14 +38,12 @@ type Props = {
|
|||||||
initialScale: number
|
initialScale: number
|
||||||
initialTranslate: Position
|
initialTranslate: Position
|
||||||
onZoom: (isZoomed: boolean) => void
|
onZoom: (isZoomed: boolean) => void
|
||||||
doubleTapToZoomEnabled: boolean
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const usePanResponder = ({
|
const usePanResponder = ({
|
||||||
initialScale,
|
initialScale,
|
||||||
initialTranslate,
|
initialTranslate,
|
||||||
onZoom,
|
onZoom,
|
||||||
doubleTapToZoomEnabled,
|
|
||||||
}: Props): Readonly<
|
}: Props): Readonly<
|
||||||
[GestureResponderHandlers, Animated.Value, Animated.ValueXY]
|
[GestureResponderHandlers, Animated.Value, Animated.ValueXY]
|
||||||
> => {
|
> => {
|
||||||
@@ -181,7 +179,7 @@ const usePanResponder = ({
|
|||||||
lastTapTS && tapTS - lastTapTS < DOUBLE_TAP_DELAY,
|
lastTapTS && tapTS - lastTapTS < DOUBLE_TAP_DELAY,
|
||||||
)
|
)
|
||||||
|
|
||||||
if (doubleTapToZoomEnabled && isDoubleTapPerformed) {
|
if (isDoubleTapPerformed) {
|
||||||
let nextScale = initialScale
|
let nextScale = initialScale
|
||||||
let nextTranslate = initialTranslate
|
let nextTranslate = initialTranslate
|
||||||
|
|
||||||
@@ -229,7 +227,7 @@ const usePanResponder = ({
|
|||||||
gestureState: PanResponderGestureState,
|
gestureState: PanResponderGestureState,
|
||||||
) => {
|
) => {
|
||||||
// Don't need to handle move because double tap in progress (was handled in onStart)
|
// Don't need to handle move because double tap in progress (was handled in onStart)
|
||||||
if (doubleTapToZoomEnabled && isDoubleTapPerformed) {
|
if (isDoubleTapPerformed) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -46,7 +46,6 @@ type Props = {
|
|||||||
animationType?: ModalProps['animationType']
|
animationType?: ModalProps['animationType']
|
||||||
backgroundColor?: string
|
backgroundColor?: string
|
||||||
swipeToCloseEnabled?: boolean
|
swipeToCloseEnabled?: boolean
|
||||||
doubleTapToZoomEnabled?: boolean
|
|
||||||
HeaderComponent?: ComponentType<{imageIndex: number}>
|
HeaderComponent?: ComponentType<{imageIndex: number}>
|
||||||
FooterComponent?: ComponentType<{imageIndex: number}>
|
FooterComponent?: ComponentType<{imageIndex: number}>
|
||||||
}
|
}
|
||||||
@@ -64,7 +63,6 @@ function ImageViewing({
|
|||||||
onImageIndexChange,
|
onImageIndexChange,
|
||||||
backgroundColor = DEFAULT_BG_COLOR,
|
backgroundColor = DEFAULT_BG_COLOR,
|
||||||
swipeToCloseEnabled,
|
swipeToCloseEnabled,
|
||||||
doubleTapToZoomEnabled,
|
|
||||||
HeaderComponent,
|
HeaderComponent,
|
||||||
FooterComponent,
|
FooterComponent,
|
||||||
}: Props) {
|
}: Props) {
|
||||||
@@ -144,7 +142,6 @@ function ImageViewing({
|
|||||||
imageSrc={imageSrc}
|
imageSrc={imageSrc}
|
||||||
onRequestClose={onRequestCloseEnhanced}
|
onRequestClose={onRequestCloseEnhanced}
|
||||||
swipeToCloseEnabled={swipeToCloseEnabled}
|
swipeToCloseEnabled={swipeToCloseEnabled}
|
||||||
doubleTapToZoomEnabled={doubleTapToZoomEnabled}
|
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
onMomentumScrollEnd={onScroll}
|
onMomentumScrollEnd={onScroll}
|
||||||
|
|||||||
Reference in New Issue
Block a user