Animated.View
を垂直方向に移動するためのPanResponderを作成しました。私はそれを元の位置から移動するとうまくいきますが、もう一度2度移動すると元の位置にスナップしてからタッチに相対的に移動します。PanResponderは2番目のドラッグ時にAnimated.Viewを元の位置にスナップします
レスポンダをAnimated.View
に直接アンパックしていますが、何らかの原因でこの問題が発生している可能性がありますか?ここで
は私PanResponderを定義する方法である:
this.state = {
drag: new Animated.ValueXY()
}
this._responder = PanResponder.create({
onStartShouldSetPanResponder:() => true,
onPanResponderMove: Animated.event([null, {
dy: this.state.drag.y
}]),
onPanResponderRelease: (e, coords) => {
...
}
})
そして、私のAnimated.View
に応答を適用する:
<Animated.View {...this._responder.panHandlers} style={this.state.drag.getLayout()}>
// children go here
</Animated.View>
おかげ
この偉大な回答で対応し、何が起こっているのかを正しく説明していただき、ありがとうございます。私はあなたが提供したものと同様の方法を使ってこの問題を最終的に解決しました。 – JmJ