RN 三星S7 点击和 滑动事件冲突

RN 三星S7 点击和 滑动事件冲突

目的

PanResponder监听外层View ,并包裹TouchableWithoutFeedback 来实现,当点击其中的TouchableWithoutFeedback 触发开关灯动作 即按钮事件,手指落到TouchableWithoutFeedback 上往外滑动触发上下滑动 用来调节亮度

  <View style={styles.verticalView}  {...this._panResponder.panHandlers}>
              <TouchableWithoutFeedback  style={{position:'absolute', height:120*ratio,width:120*ratio}} onPress={()=>this.setPower()}>
                  <Image style={{
                    opacity:this.calculateCurrentBri(),
                    tintColor:this.gradient(parseInt(this.state.valueCct*100.0/(200*ratio))),height:120*ratio,width:120*ratio,backgroundColor:'transparent'}} 
                      source={picSource} />
              </TouchableWithoutFeedback>
            </View>
现象

滑动事件抢去点击的事件,点击出现不灵敏

解决方法

用另外一种方式监听滑动手势,就可以解决


            <View onStartShouldSetResponder={() => true} onResponderGrant={(e) => { this._onTouchDown(e) }} onResponderMove={(e) => this._onouchMove(e)} onResponderRelease={(e) => { this.onouchUp(e) }}>

            </View>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值