瀏覽代碼

Stop svg dragging when mouse is released outside the window. (#189)

Sanjay Ghemawat 7 年之前
父節點
當前提交
bfbedfac5c
共有 1 個檔案被更改,包括 6 行新增0 行删除
  1. 6
    0
      internal/driver/webhtml.go

+ 6
- 0
internal/driver/webhtml.go 查看文件

@@ -257,6 +257,12 @@ function initPanAndZoom(svg, clickHandler) {
257 257
   }
258 258
 
259 259
   function handleScanMove(e) {
260
+    if (e.buttons == 0) {
261
+      // Missed an end event, perhaps because mouse moved outside window.
262
+      setMode(IDLE)
263
+      svg.removeEventListener("mousemove", handleScanMove)
264
+      return
265
+    }
260 266
     if (mode == MOUSEPAN) panMove(e.clientX, e.clientY)
261 267
   }
262 268