加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

react-native – 参数panHandlers处理多个PanResponder?

发布时间:2020-12-15 20:19:24 所属栏目:百科 来源:网络整理
导读:假设我有两个简单的动画视图.我想知道哪个View被淘汰了.如何将任何参数传递给它或以任何其他方式检测?谢谢 Animated.View {...this._panResponder.panHandlers}/Animated.ViewAnimated.View {...this._panResponder.panHandlers}/Animated.View 解决方法 我
假设我有两个简单的动画视图.我想知道哪个View被淘汰了.如何将任何参数传递给它或以任何其他方式检测?谢谢

<Animated.View {...this._panResponder.panHandlers}></Animated.View>
<Animated.View {...this._panResponder.panHandlers}></Animated.View>

解决方法

我没有测试过这个,但我认为你应该能够为每个视图创建不同的响应者,类似于下面的例子.

this._firstPanResponder = PanResponder.create({
  onPanResponderGrant: (evt,gestureState) => {
    // Do something when the first responder is granted
    this.doFirst();
  },});
this._secondPanResponder = PanResponder.create({
  onPanResponderGrant: (evt,gestureState) => {
    // Do something when the second responder is granted
    this.doSecond();
  },});

那么视图应该看起来像这样.

<Animated.View {...this._firstPanResponder.panHandlers}></Animated.View>
<Animated.View {...this._secondPanResponder.panHandlers}></Animated.View>

希望这可以帮助.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读