From 0aa8820a90a0f93a603c3cba1ce5d23e6a9f3c80 Mon Sep 17 00:00:00 2001 From: Bobbie Goede Date: Thu, 11 Mar 2021 18:19:25 +0100 Subject: [PATCH] fix: do not set mouseout event delay when user is not dragging label (#135) --- src/marker.ts | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/src/marker.ts b/src/marker.ts index d4d9be8..4a175f3 100644 --- a/src/marker.ts +++ b/src/marker.ts @@ -159,26 +159,33 @@ export class MarkerWithLabel extends MarkerSafe { if (this.mouseOutTimeout) { clearTimeout(this.mouseOutTimeout); } - this.mouseOutTimeout = setTimeout(() => { - if (this.isMouseDownOnLabel) { - this.isMouseDownOnLabel = false; - google.maps.event.trigger(this, MOUSEUP, { - latLng: this.getPosition(), - }); - if (this.isDraggingLabel) { - this.isDraggingLabel = false; - this.shouldIgnoreClick = true; - google.maps.event.trigger(this, DRAGEND, { + if (this.isMouseDownOnLabel) { + this.mouseOutTimeout = setTimeout(() => { + if (this.isMouseDownOnLabel) { + this.isMouseDownOnLabel = false; + google.maps.event.trigger(this, MOUSEUP, { latLng: this.getPosition(), }); + + if (this.isDraggingLabel) { + this.isDraggingLabel = false; + this.shouldIgnoreClick = true; + google.maps.event.trigger(this, DRAGEND, { + latLng: this.getPosition(), + }); + } } - } + google.maps.event.trigger(this, MOUSEOUT, { + latLng: this.getPosition(), + }); + }, 200); + } else { google.maps.event.trigger(this, MOUSEOUT, { latLng: this.getPosition(), }); - }, 200); + } abortEvent(e); }