Variable type change
If the "from" you've shown works (or worked when you were using jQuery), canvas2
is or was a jQuery object (most likely). The rough equivalent is your first line, but on the DOM element inside it:
canvas2[0].addEventListener('mousedown',function(e){handleMouseMove(e);});
or indeed, simply:
canvas2[0].addEventListener('mousedown', handleMouseMove);
Naturally, if you're trying to migrate code away from jQuery, you'll probably end up changing canvas2
to something else, perhaps a straight DOM object. If so, drop the [0]
from the above when you do that. But as the first line of the things you've tried would have worked if that were already done, hopefully the above helps.
Side note: You changed from handleMouseDown
to handleMouseMove
in your examples. I've faithfully done that above, but do be sure you're using mousedown
with handleMouseDown
and mousemove
with handleMouseMove
...