我试图创建垂直平面表与滑动删除功能。因此,我的平面列表中的每一项都是由PanGestureHandler处理的,我的问题是,当我试图滚动平面列表滚动时,由于滚动视图动画和pan手势动画之间的冲突,所以无法工作。我试过使用simultaneousHandlers,但没有用。我还尝试使用来自react-native-gesture-handler的react-native-gesture-handler和来自react-native的结果是相同的。
<View style={styles.container}>
<Header data={{headerText: 'Contacts', leftIcon: 'arrow-left', line: true}}/>
<FlatList
ref={scrollRef}
data={contacts}
renderItem={({item}) => <Item simultaneousHandlers={scrollRef} {...{item}} />}
bounces={false}
showsVerticalScrollIndicator={false}
style={{paddingLeft: wp('5%'), paddingTop: hp('2%')}}>
</FlatList>
<TouchableOpacity style={styles.touchableOpacity} onPress={() => navigation.navigate('AddContact')}>
<View>
<Text style={styles.textButton}> Add Contact </Text>
</View>
</TouchableOpacity>
</View>项目:
<Animated.View style={[rTaskContainerStyle]}>
<Animated.View style={[styles.iconContainer, rIconContainerStyle]}>
<Icon name={'trash-2'} size={25} color={'red'} />
</Animated.View>
<View>
<PanGestureHandler {...simultaneousHandlers} onGestureEvent={panGestureHandler}>
<Animated.View style={[rStyle,{backgroundColor: '#FFFFFF'}]}>
<Text style={{color: '#09101D', fontFamily: 'SourceSansPro_600SemiBold', fontSize: 18}}>
{info.fullName}
</Text>
<Text style={{color: '#545D69', fontFamily: 'SourceSansPro_400Regular'}}>
{info.publicKey}
</Text>
</Animated.View>
</PanGestureHandler>
</View>
</Animated.View>发布于 2022-03-14 06:54:58
您应该为泛手势添加偏移量。你的PanGestureHanler应该是
<PanGestureHandler
failOffsetY={[-5, 5]}
activeOffsetX={[-5, 5]}
onGestureEvent={gestureHandler}
>可能对你有帮助。
https://stackoverflow.com/questions/71325340
复制相似问题