Femi Oni
Femi Oni

Reputation: 824

react native webview event listener passes empty event object to callback

building a html canvas page in react-native webview. everything seem fine except the canvas.addEventListener call the call back with empty event object

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

Upvotes: 0

Views: 1111

Answers (1)

Chris
Chris

Reputation: 1058

I have been struggling with the exact same thing. Regular events through DOM or jQuery didn't work for me, but the following did.

canvas.ontouchmove = function(e) {
    //e.pageX;
    //e.pageY;
};

Upvotes: 1

Related Questions