相关平台
React Native
使用框架: React
复现步骤
onTouch = (e,type) => {console.log('type:',type,' e:',e)}//start才有
render() {
let {canScrollY, blockStyle, downLoading} = this.state
return (
// <ScrollView
// className={`${!downLoading && "downLoading"} refresh-view`}
// scrollY={canScrollY}
// scrollWithAnimation
// onScroll={this.onScroll}>
<View
catchMove
className='refresh-view-content'
onTouchStart={e => this.onTouch(e,'touchstart')}
onTouchMove={e => this.onTouch(e,'touchmove')}
onTouchEnd={e => this.onTouch(e,'touchend')}
onTouchCancel={e => this.onTouch(e,'touchcancel')}>
<View style={blockStyle}>
<View style={{height: 100, marginTop: -100}} className='pullDownBlock'> </View>
{this.props.children}
</View>
</View>
// </ScrollView>
)
}
期望结果
onTouchMove的时候,可以像onTouchStart一样返回滑动坐标信息:{"changedTouches": [{"clientX": 121, "clientY": 311.5, "identifier": 0, "pageX": 121, "pageY": 402}], "currentTarget": {"dataset": {}, "id": 2097}, "detail": {"x": 121, "y": 402}, "target": {"dataset": {}, "id": 2097}, "timeStamp": 963577153, "touches": [{"clientX": 121, "clientY": 311.5, "identifier": 0, "pageX": 121, "pageY": 402}], "type": "tap"}
实际结果
onTouchMove返回如下(信息太长无法提交)
里面没有返回坐标信息
环境信息
Taro CLI 3.6.1 environment info:
System:
OS: Windows 10
Binaries:
Node: 16.9.1 - D:\nodejs\node.EXE
Yarn: 1.22.19 - D:\nodejs\yarn.CMD
npm: 7.21.1 - D:\nodejs\npm.CMD
3条答案
按热度按时间svdrlsy41#
支付宝小程序表现正常,RN不行
2mbi3lxu2#
并且touchMove执行2-3次之后,直接跳到了touchcancel回调中,就没有后续触摸事件了
to94eoyn3#
看源码发现 RN 的 View 的 onTouchMove onTouchCancel 相关代码注释掉了,所以是没有实现这两个事件,不清楚是什么原因