commit 56afa3d432b37c8c4a69c541dc2df9bd776c6412
parent 2dafe9016f8c95e798f6fda9f84a90f2b6fab772
Author: Sergej Orlov <wladimirych@gmail.com>
Date: Mon, 5 Nov 2018 23:25:11 +0100
add option to Tooltip to delay open on mouseenter event
Diffstat:
1 file changed, 19 insertions(+), 0 deletions(-)
diff --git a/src/lib/leaflet.fixes/index.js b/src/lib/leaflet.fixes/index.js
@@ -6,6 +6,7 @@ function fixAll() {
fixTouchDetection();
fixMapKeypressEvent();
fixVectorDrawWhileAnimation();
+ addTooltipDelay();
}
// https://github.com/Leaflet/Leaflet/issues/3575
@@ -78,4 +79,22 @@ function fixVectorDrawWhileAnimation() {
L.Renderer.__animationFixed = true;
}
+function addTooltipDelay() {
+ const origOpenTooltip = L.Layer.prototype._openTooltip;
+ L.Layer.prototype._openTooltip = function(e) {
+ if (this._tooltip.options.delay) {
+ const self = this;
+ this._pendingTooltip = setTimeout(() => origOpenTooltip.call(self, e), this._tooltip.options.delay);
+ } else {
+ origOpenTooltip.call(this, e);
+ }
+ };
+
+ const origCloseTooltip = L.Layer.prototype.closeTooltip;
+ L.Layer.prototype.closeTooltip = function() {
+ clearInterval(this._pendingTooltip);
+ origCloseTooltip.call(this);
+ }
+}
+
export {fixAll}