我在使用PanGestureHandler
from react-native-gesture-handler
with时遇到问题Modal
。这是完美的工作,iOS
但不是android
。此外,当我更改Modal
为View
组件时,它也可以正常工作Android
。请任何人都可以建议我解决这个问题。
class Circle extends Component {
_touchX = new Animated.Value(windowWidth / 2 - circleRadius);
_onPanGestureEvent = Animated.event([{ nativeEvent: { x: this._touchX } }], { useNativeDriver: true });
render() {
return (
<Modal
isVisible={true}
>
<PanGestureHandler
onGestureEvent={this._onPanGestureEvent}>
<Animated.View style={{
height: 150,
justifyContent: 'center',
}}>
<Animated.View
style={[{
backgroundColor: '#42a5f5', borderRadius: circleRadius, height: circleRadius * 2, width: circleRadius * 2,
}, {
transform: [{ translateX: Animated.add(this._touchX, new Animated.Value(-circleRadius)) }]
}]}
/>
</Animated.View>
</PanGestureHandler>
</Modal>
);
}
}