Fix reopened tooltip getting closed by timer
Cases: - enabled tooltip gets closed after disable + re-enable - disabled tooltip gets closed after create + re-hover Superfluous clearTimeout calls in the regular case after timeout have no effect.
This commit is contained in:
parent
35a1547e70
commit
4740048960
1 changed files with 13 additions and 7 deletions
|
|
@ -263,15 +263,24 @@ BR.EditingTooltip = L.Handler.extend({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_setCloseTimeout: function(layer) {
|
||||||
|
var timeoutId = setTimeout(function () {
|
||||||
|
layer.closeTooltip();
|
||||||
|
}, this.options.closeTimeout);
|
||||||
|
|
||||||
|
// prevent timer to close tooltip that changed in the meantime
|
||||||
|
layer.once('tooltipopen', function (e) {
|
||||||
|
clearTimeout(timeoutId);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
_postCreate: function () {
|
_postCreate: function () {
|
||||||
// editing is disabled by another handler, tooltip won't stay open before
|
// editing is disabled by another handler, tooltip won't stay open before
|
||||||
this.editTools.once('editable:disable', function (e) {
|
this.editTools.once('editable:disable', function (e) {
|
||||||
|
|
||||||
// show for a few seconds, as mouse often not hovering circle after create
|
// show for a few seconds, as mouse often not hovering circle after create
|
||||||
e.layer.openTooltip(e.layer);
|
e.layer.openTooltip(e.layer);
|
||||||
setTimeout(function () {
|
this._setCloseTimeout(e.layer);
|
||||||
e.layer.closeTooltip();
|
|
||||||
}, this.options.closeTimeout);
|
|
||||||
}, this);
|
}, this);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -285,10 +294,7 @@ BR.EditingTooltip = L.Handler.extend({
|
||||||
|
|
||||||
_disable: function (e) {
|
_disable: function (e) {
|
||||||
e.layer.setTooltipContent(BR.NogoAreas.MSG_DISABLED);
|
e.layer.setTooltipContent(BR.NogoAreas.MSG_DISABLED);
|
||||||
|
this._setCloseTimeout(e.layer);
|
||||||
setTimeout(function () {
|
|
||||||
e.layer.closeTooltip();
|
|
||||||
}, this.options.closeTimeout);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue