fix bbox destructor, closes #81 for real

This commit is contained in:
ed 2024-04-09 19:10:55 +00:00
parent f89de6b35d
commit 4f0cad5468

View file

@ -583,7 +583,7 @@ window.baguetteBox = (function () {
isOverlayVisible = true; isOverlayVisible = true;
} }
function hideOverlay(e) { function hideOverlay(e, dtor) {
ev(e); ev(e);
playvid(false); playvid(false);
removeFromCache('#files'); removeFromCache('#files');
@ -592,19 +592,21 @@ window.baguetteBox = (function () {
document.body.style.overflowY = 'auto'; 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) if (options.duringHide)
options.duringHide(); options.duringHide();
if (overlay.style.display === 'none')
return;
sethash(''); sethash('');
unbindEvents(); unbindEvents();
try {
document.exitFullscreen();
isFullscreen = false;
}
catch (ex) { }
// Fade out and hide the overlay // Fade out and hide the overlay
overlay.className = ''; overlay.className = '';
@ -1065,6 +1067,7 @@ window.baguetteBox = (function () {
} }
function destroyPlugin() { function destroyPlugin() {
hideOverlay(undefined, true);
unbindEvents(); unbindEvents();
clearCachedData(); clearCachedData();
document.getElementsByTagName('body')[0].removeChild(ebi('bbox-overlay')); document.getElementsByTagName('body')[0].removeChild(ebi('bbox-overlay'));