[英]react native webview event listener passes empty event object to callback
building a html canvas page in react-native webview. 在react-native webview中建立一个HTML画布页面。 everything seem fine except the canvas.addEventListener
call the call back with empty event object 除了canvas.addEventListener
用空的事件对象回叫外, canvas.addEventListener
一切看起来都很好
var moveEvents = ["mousemove", "touchmove"]
moveEvents.forEach(function (moveEvent) {
canvas.addEventListener(moveEvent, function(e) {
console.log(e) // {}
mouse.x = e.pageX - this.offsetLeft;
mouse.y = e.pageY - this.offsetTop;
}, false);
don't know what could possible be wrong this behavior is only noticed on react-native here is the code working as expected on jsfiddle 不知道这可能是什么错误,此行为仅在react-native上注意到,这是jsfiddle上的代码按预期工作
I have been struggling with the exact same thing. 我一直在努力寻找完全相同的东西。 Regular events through DOM or jQuery didn't work for me, but the following did. 通过DOM或jQuery进行的常规事件对我来说不起作用,但以下内容对我来说无效。
canvas.ontouchmove = function(e) {
//e.pageX;
//e.pageY;
};
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.