Răsfoiți Sursa

fix up onPointerUp

Adam Shaw 7 ani în urmă
părinte
comite
c9b37eb59c
1 a modificat fișierele cu 11 adăugiri și 4 ștergeri
  1. 11 4
      src/common/browser-context.ts

+ 11 - 4
src/common/browser-context.ts

@@ -75,12 +75,19 @@ export class BrowserContext {
   }
 
   onPointerUp = (ev) => {
-    let { listenerHash } = this
-    let { wasTouchScroll, downEl } = this.pointer
+    let { listenerHash, pointer } = this
+
+    // trickiness about sending pointer-up to these components:
+    // pointer might be null, but if so, all components were destroyed and the following loops won't execute.
+    // also, a onDocumentPointerUp call might cause the component to be destroyed, so break into separate loops
+    // and freshly access listenerHash every time.
+
+    for (let id in listenerHash) {
+      listenerHash[id].dateSelecting.onDocumentPointerUp(ev, pointer.wasTouchScroll, pointer.downEl)
+    }
 
     for (let id in listenerHash) {
-      listenerHash[id].dateSelecting.onDocumentPointerUp(ev, wasTouchScroll, downEl)
-      listenerHash[id].eventDragging.onDocumentPointerUp(ev, wasTouchScroll, downEl)
+      listenerHash[id].eventDragging.onDocumentPointerUp(ev, pointer.wasTouchScroll, pointer.downEl)
     }
   }