From 4f0cad5468d7ea6083be16fbd18225ce33a86e6f Mon Sep 17 00:00:00 2001 From: ed Date: Tue, 9 Apr 2024 19:10:55 +0000 Subject: [PATCH] fix bbox destructor, closes #81 for real --- copyparty/web/baguettebox.js | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/copyparty/web/baguettebox.js b/copyparty/web/baguettebox.js index 3c031f05..21d9cba3 100644 --- a/copyparty/web/baguettebox.js +++ b/copyparty/web/baguettebox.js @@ -583,7 +583,7 @@ window.baguetteBox = (function () { isOverlayVisible = true; } - function hideOverlay(e) { + function hideOverlay(e, dtor) { ev(e); playvid(false); removeFromCache('#files'); @@ -592,19 +592,21 @@ window.baguetteBox = (function () { document.body.style.overflowY = 'auto'; } + try { + if (document.fullscreenElement) + document.exitFullscreen(); + } + catch (ex) { } + isFullscreen = false; + + if (dtor || overlay.style.display === 'none') + return; + if (options.duringHide) options.duringHide(); - if (overlay.style.display === 'none') - return; - sethash(''); unbindEvents(); - try { - document.exitFullscreen(); - isFullscreen = false; - } - catch (ex) { } // Fade out and hide the overlay overlay.className = ''; @@ -1065,6 +1067,7 @@ window.baguetteBox = (function () { } function destroyPlugin() { + hideOverlay(undefined, true); unbindEvents(); clearCachedData(); document.getElementsByTagName('body')[0].removeChild(ebi('bbox-overlay'));