javascript - How do I ensure robust notification of mouseup? -


the goal reliably notified of mouseup events. concrete example, when left-click cloud should turn red , when release button should return blue.

this fiddle works:

canvas.addeventlistener("mousedown", function(e) {     if (e.button === 0) {         drawshape("#ff69b4", "red");     } }); canvas.addeventlistener("mouseup", function(e) {     if (e.button === 0) {         drawshape("#8ed6ff", "blue");     } }); window.addeventlistener("mouseup", function(e) {     if (e.button === 0) {         drawshape("#8ed6ff", "blue");     } }, true); 

https://jsfiddle.net/f1x6vc0c/1/

the great evil remains context menu. if click cloud, drag anywhere like, , right-click context menu , release left mouse button while context menu present mouseup forever lost. sure, disable context menu, on pages control - note same aberrant behavior occurs if activate context-menu in other app outside browser window. so, how ensure notified in case? in cross-browser manner?

(feel free ignore ie prior 9 , elder browsers)


Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -