Syntax error How to handle mousedown and mouseup with HTML5 Canvas

How to handle mousedown and mouseup with HTML5 Canvas



To handle the mousedown and mouseup event with HTML5 Canvas,

var mouseDown = false;

// for mousedown
canvas1.onmousedown = function(event){
   dragOffset.x = event.x - mainLayer.trans.x;
   dragOffset.y = event.y - mainLayer.trans.y;
   mouseDown = true;
}

// for mouseup
canvas1.onmouseup = function(event){
   if(mouseDown) mouseClick(eevent
   mouseDown = false;
}
Updated on: 2020-01-27T10:52:11+05:30

833 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements