Use once to call event handler just one time

Use dedicated option, don't do it manually.

https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#once

Signed-off-by: Szymon Kłos <szymon.klos@collabora.com>
Change-Id: I2bce09c496ca7dd3267514bbb30308b7f7afe4f9
This commit is contained in:
Szymon Kłos 2024-01-19 10:34:47 +01:00 committed by Szymon Kłos
parent d331120059
commit 6546ab4501

View file

@ -1033,11 +1033,10 @@ L.Control.UIManager = L.Control.extend({
elem.tooltip('option', 'items', elem[0]);
elem.tooltip('option', 'position', { my: 'left bottom', at: 'left+' + pt.x + ' top+' + pt.y, collision: 'fit fit' });
elem.tooltip('open');
document.addEventListener('mousemove', function closeTooltip() {
document.addEventListener('mousemove', function() {
elem.tooltip('close');
elem.tooltip('disable');
document.removeEventListener('mousemove', closeTooltip);
});
}, {once: true});
},
// Snack bar