0

I have a component wrapped with react-native-swipe-gestures

import React from 'react'
import GestureRecognizer from 'react-native-swipe-gestures';
import Carousel from 'react-native-reanimated-carousel'

const MyComponent = () => {
  return (
    <GestureRecognizer 
      onSwipeLeft={() => { handleSwipeTask('left') }}
      onSwipeRight={() => { handleSwipeTask('right') }}
    >
      {/* 
        some view children
      */}
      <Carousel
        loop
        width={size.width}
        height={size.height}
        autoPlay={false}
        data={lists}
        scrollAnimationDuration={2000}
        onSnapToItem={e => console.log(e)}
        renderItem={({ item, index }) => {
          return (
            <View
                style={{
                    width: '100%',
                    borderWidth: 1,
                    justifyContent: 'center',
                }}
            >
                <FastImage
                  key={`attachment-${index}`}
                  style={{
                    width: '100%',
                    height: '100%',
                  }}
                  source={
                    local ? item.file_path
                    : {
                      uri: item.file_path,
                      priority: FastImage.priority.normal,
                      // cache: FastImage.cacheControl.cacheOnly
                    }
                  }
                  resizeMode={FastImage.resizeMode.contain}
                />
            </View>
        )
        }}
        autoPlayInterval={4000}
        pagingEnabled={true}
      />
      {/* 
        some view children
      */}
    </GestureRecognizer>
  )
}

with the gesture reconigzer when i swipe left or right i have to change the data of the view with handleSwipeTask method; it work well and in the data i have an array of images to show as carousel; so using react-native-reanimated-carousel i made my carousel working; but my issue when i swipe manually the caroussel my gesture recognizer detect the swipe and with the caroussel sliding my handleSwipeTask is triggered too; so what i want is to disable that recognition only for my caroussel component; i don't want to wrap every view exluding the caroussel on the gesture recognizer (it's my last option if there is no solution)

Iva
  • 2,447
  • 1
  • 18
  • 28
Michel Gisenaƫl
  • 211
  • 1
  • 2
  • 15

0 Answers0