diff --git a/bin/web/js/audio.js b/bin/web/js/audio.js index 11546bc..94c7687 100644 --- a/bin/web/js/audio.js +++ b/bin/web/js/audio.js @@ -361,12 +361,24 @@ const Audio = function(tp, record) { mappingOptions.max_in = (bb.height - min_y) * y_factor; } }); - fft_Dom.addEventListener('mouseup', (e) => { + const unset = (e) => { setFrequency = false; + }; + const unsetFromOutside = (e) => { + document.removeEventListener('mouseup', unsetFromOutside); + unset(e); + }; + fft_Dom.addEventListener('mouseup', unset); + fft_Dom.addEventListener('mouseleave', (e) => { + if (setFrequency) { + document.addEventListener('mouseup', unsetFromOutside); + } + }); + fft_Dom.addEventListener('mouseenter', (e) => { + if (setFrequency) { + document.removeEventListener('mouseup', unsetFromOutside); + } }); - //fft_Dom.addEventListener('mouseout', (e) => { - //setFrequency = false; - //}); container.after(audioOptions);