![](/img/trans.png)
[英]PanResponder could not detect touch if i touch on Touchables(TouchableHighlight, TouchableOpacity, TouchableWithoutFeedback)
[英]How can I detect if the touch is over the border of a View from PanResponder?
我正在研究图像裁切器,尽管它不是一个完美的解决方案,但我仍然以某种方式想出了如何移动裁切器,但是它可以工作,但是现在我想响应给定视图的边框触摸/移动
我正在使用此模块进行整合,但实际上我仍然停留在如何响应边框触摸/移动的问题上
gestureState参数足以完成任务。
x0和y0是响应者视图的左上角坐标,此外, moveX
和moveY
保留触摸的当前坐标。
因此moveX === x0
表示当前触摸位于左边缘。 同样, moveY === y0
表示当前触摸位于顶部边缘。
为了处理右边缘和下边缘,建议您使用<View>
标记中的onLayout
并将<View>
高度和宽度分配给某些变量或状态变量(请注意性能优化)
然后以类似方式使用它:
onPanresponderMove(evt, {x0, y0, moveX, moveY) {
...
if(moveX=== x0 || moveX === x0 + this.state._currentWidth) {
// task for left and right edge response
...
}
...
}
获取视图宽度:
<View {...this._myResponder.panHandlers}
onLayout={ ({width, height}) => this.state._currentWidth = width } />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.