[英]How to unbind PanResponder for <View>
How can I unbind PanResponder on a View. 如何在视图上解除绑定PanResponder。 Also, how do I unmount a View altogether?
另外,如何完全卸载视图?
I tried to remove it by setting it to null but that would break in case of further renders. 我试图通过将其设置为null来删除它,但是在进一步渲染的情况下会中断。
handlePanResponderEnd: function(evt: Object, gestureState: Object){
if (Math.abs(this.translate) > width/4){
var setoff = -(2 * width);
var that = this;
this.nextItem = <View style={styles.container} ><Story data={this.data[that.state.currentItem + 2]} /></View>;
this.setState({ left: setoff, currentItem: this.state.currentItem + 1 });
// this.setPanResponder();
} else {
this.setState({ left: this.translate });
}
}
Have you tried using conditional rendering? 您是否尝试过使用条件渲染? You can wrap or not your component with Animated.View depending on a value you check.
您可以使用Animated.View包裹组件,也可以不包裹,这取决于您检查的值。 Something like this:
像这样:
{renderAnimated ?
<Animated.View>{this.renderMyContent()}<Animated.View>
: {this.renderMyContent()}
}
Or you can set your PanResponder const to a PanResponder.create() or null depending 或者,您可以将PanResponder常量设置为PanResponder.create()或null,具体取决于
const panResponder = shouldPanResponder ? PanResponder.create({...}) : null
Hope it helps. 希望能帮助到你。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.