简体   繁体   English

画布画出屏幕错误

[英]Canvas draw out of screen bug

I'm working on drawing app and I encountered one problem. 我正在开发绘图应用程序,但遇到了一个问题。 When user moves out of screen(to taskbar or browser topbar,...) and then moves back on another place, app just draws line to that point. 当用户移出屏幕(移至任务栏或浏览器顶部栏,...),然后移回另一位置时,应用程序会画线到该点。 Is there some way how to stop drawing when user moves out and resume when he enters back (without drawing that additional line)? 有什么方法可以在用户移出时停止绘制并在用户返回时继续显示(不绘制该附加线)?

Add event.preventDefault() to you mouseout handler. 将event.preventDefault()添加到鼠标移出处理程序。

    function handleMouseOut(e){
      e.preventDefault();
      mouseX=parseInt(e.clientX-offsetX);
      mouseY=parseInt(e.clientY-offsetY);

      // Put your mouseOut stuff here
      isDown=false;
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM