From b50dbffa8a7c3bdf263f0b2d941499e80fb4f9e8 Mon Sep 17 00:00:00 2001 From: Filippo Cattuzzo Date: Sat, 23 Jun 2018 00:14:28 +0100 Subject: [PATCH] Added whitelistedMouseEvent option to set an (optional) list of events whose execution wll not be stopped --- README.md | 11 +++++++++++ src/snazzy-info-window.js | 9 ++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index cbb5085..36f4b93 100644 --- a/README.md +++ b/README.md @@ -322,6 +322,17 @@ Determines if the info window will be panned into view when opened. - Type: _boolean_ - Default: `true` +#### whitelistedMouseEvents + +An optional list of mouse events whose execution will not be stopped when the event occurs. + +- Type: _array_ +- Example: + + ```js + whitelistedMouseEvents: ['mousedown', 'mouseup'] + ``` + ### callbacks All callbacks are optional and can access the info window instance via `this`. diff --git a/src/snazzy-info-window.js b/src/snazzy-info-window.js index e9c47cc..0dcf70b 100644 --- a/src/snazzy-info-window.js +++ b/src/snazzy-info-window.js @@ -602,11 +602,18 @@ export default class SnazzyInfoWindow extends getGoogleClass() { } // Stop the mouse event propagation - const mouseEvents = ['click', 'dblclick', 'rightclick', 'contextmenu', + let mouseEvents = ['click', 'dblclick', 'rightclick', 'contextmenu', 'drag', 'dragend', 'dragstart', 'mousedown', 'mouseout', 'mouseover', 'mouseup', 'touchstart', 'touchend', 'touchmove', 'wheel', 'mousewheel', 'DOMMouseScroll', 'MozMousePixelScroll']; + if (this._opts.whitelistedMouseEvents) { + const whitelistedEvents = this._opts.whitelistedMouseEvents; + mouseEvents = mouseEvents.filter((event) => { + return whitelistedEvents.indexOf(event) < 0; + }); + } + mouseEvents.forEach((event) => { this.trackListener(google.maps.event.addDomListener(this._html.wrapper, event, (e) => {