From afb09061194f1b69911afca4efa0feeb6efe3dac Mon Sep 17 00:00:00 2001 From: "Manu Mtz.-Almeida" Date: Wed, 1 Aug 2018 19:08:56 +0200 Subject: [PATCH] fix(pointer-events): listening to document --- core/src/utils/gesture/pointer-events.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/core/src/utils/gesture/pointer-events.ts b/core/src/utils/gesture/pointer-events.ts index f37a91896f..a408cf4c37 100644 --- a/core/src/utils/gesture/pointer-events.ts +++ b/core/src/utils/gesture/pointer-events.ts @@ -85,10 +85,10 @@ export class PointerEvents { return; } if (!this.rmMouseMove && this.pointerMove) { - this.rmMouseMove = addEventListener(this.el.ownerDocument, 'mousemove', this.pointerMove, this.options); + this.rmMouseMove = addEventListener(getDocument(this.el), 'mousemove', this.pointerMove, this.options); } if (!this.rmMouseUp) { - this.rmMouseUp = addEventListener(this.el.ownerDocument, 'mouseup', this.bindMouseUp, this.options); + this.rmMouseUp = addEventListener(getDocument(this.el), 'mouseup', this.bindMouseUp, this.options); } } @@ -130,6 +130,10 @@ export class PointerEvents { } } +function getDocument(node: Node) { + return node instanceof Document ? node : node.ownerDocument; +} + export const POINTER_EVENT_TYPE_MOUSE = 1; export const POINTER_EVENT_TYPE_TOUCH = 2;