gpt4 book ai didi

reactjs - 在移动期间响应 native 停止平移手势

转载 作者:行者123 更新时间:2023-12-04 13:46:05 24 4
gpt4 key购买 nike

我想停止 PanResponder系统仍在移动时。即如果满足条件,则取消或结束手势。

我有一个 Animated.Value连接到手势和该值的监听器。如果大于 100,我想暂停平移手势。

最佳答案

您可以停止 PanReponder系统通过启用 PanResponder在父 View 上。

来自 documentation , 我们有:

onStartShouldSetResponder and onMoveShouldSetResponder are called with a bubbling pattern, where the deepest node is called first. That means that the deepest component will become responder when multiple Views return true for *ShouldSetResponder handlers. This is desirable in most cases, because it makes sure all controls and buttons are usable.

However, sometimes a parent will want to make sure that it becomes responder. This can be handled by using the capture phase. Before the responder system bubbles up from the deepest component, it will do a capture phase, firing on*ShouldSetResponderCapture. So if a parent View wants to prevent the child from becoming responder on a touch start, it should have a onStartShouldSetResponderCapture handler which returns true.



在您的情况下,您应该在满足条件时为父 View 设置 onMoveShouldSetPanResponderCapture。
onMoveShouldSetPanResponderCapture: () => this.isMyConditionTrue(),

并且,还要在子响应者上设置以下属性:
onPanResponderTerminationRequest: () => true,

为了让父级捕获响应者。

关于reactjs - 在移动期间响应 native 停止平移手势,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48054217/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com