我有一个可拖动的水平视图(比例尺)。为了使其可水平拖动,在componentDidMount
中,我添加了:
this.currentPanValue = 0;
this.panListener = this.state.pan.addListener((value) => this.currentPanValue = value);
在组件状态下,我有一个dragX: new Animated.Value(0)
。将PanResponder设置为:
onPanResponderRelease: (e, gestureState) => {
this.state.dragX.setOffset(this.currentPanValue);
this.state.dragX.setValue(0);
},
...使其可水平拖动,全部设置!
但是,“拖延”体验并不像拥有<ScrollView horizontal={true} />
。
我想知道有什么方法可以使PanResponder的拖动体验像拖动ScrollView一样-具有相同的“缓和”,“弹跳”,“速度”等?