Search code examples
javascripthtml5-canvastouchmove

touchmove event has empty event data


nevermind i realize that 'JSON.stringify(evt)' does not print out the data in the event object ????

original question:

i have

var canvas = document.createElement('canvas');

canvas.addEventListener('touchmove', function(evt)
{
  alert(JSON.stringify(evt));
},false);

when i see the alert, the 'evt' is blank. so all these posts like this one iphone's safari touchmove event not working that say to get the 'originalEvent' do not apply to me, because there is nothing in the evt at all to see.

How do i get the 'evt' to have touch data in it so that i can get touch locations with code like

var touch = evt.changedTouches[0];

?

note: The next line of code has the following mouse events which work great

canvas.addEventListener('mousemove', function(evt)
{
  alert(JSON.stringify(evt));
}, false);

Solution

  • the data is there, it's just that

    alert(JSON.stringify(evt));
    

    appears blank. not sure why JSON.stringify does not work on events, but that's my take-home messaage