如何在 HTML5 Canvas 中处理 mousedown 和 mouseup
要使用 HTML5 Canvas 处理 mousedown 和 mouseup 事件,
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; }
广告