additional cleanup when destroying #1145

This commit is contained in:
hakimel 2022-02-21 14:28:11 +01:00
parent 1e0cbe6779
commit 5e12c6aeb7
10 changed files with 62 additions and 5 deletions

2
dist/reveal.esm.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

2
dist/reveal.js vendored

File diff suppressed because one or more lines are too long

2
dist/reveal.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -394,4 +394,10 @@ export default class Backgrounds {
} }
destroy() {
this.element.remove();
}
} }

View File

@ -79,6 +79,12 @@ export default class Focus {
} }
destroy() {
this.Reveal.getRevealElement().classList.remove( 'focused' );
}
onRevealPointerDown( event ) { onRevealPointerDown( event ) {
this.focus(); this.focus();

View File

@ -111,4 +111,10 @@ export default class Notes {
} }
destroy() {
this.element.remove();
}
} }

View File

@ -101,5 +101,10 @@ export default class Progress {
} }
destroy() {
this.element.remove();
}
} }

View File

@ -123,4 +123,10 @@ export default class SlideNumber {
} }
destroy() {
this.element.remove();
}
} }

View File

@ -563,9 +563,14 @@ export default function( revealElement, options ) {
disablePreviewLinks(); disablePreviewLinks();
// Destroy controllers // Destroy controllers
notes.destroy();
focus.destroy();
plugins.destroy(); plugins.destroy();
pointer.destroy(); pointer.destroy();
controls.destroy(); controls.destroy();
progress.destroy();
backgrounds.destroy();
slideNumber.destroy();
// Remove event listeners // Remove event listeners
document.removeEventListener( 'fullscreenchange', onFullscreenChange ); document.removeEventListener( 'fullscreenchange', onFullscreenChange );
@ -575,12 +580,35 @@ export default function( revealElement, options ) {
window.removeEventListener( 'load', layout, false ); window.removeEventListener( 'load', layout, false );
// Undo DOM changes // Undo DOM changes
dom.viewport.classList.remove( 'reveal-viewport' ); if( dom.pauseOverlay ) dom.pauseOverlay.remove();
if( dom.statusElement ) dom.statusElement.remove();
document.documentElement.classList.remove( 'reveal-full-page' ); document.documentElement.classList.remove( 'reveal-full-page' );
dom.wrapper.classList.remove( 'ready', 'center', 'has-horizontal-slides', 'has-vertical-slides' );
dom.wrapper.removeAttribute( 'data-transition-speed' );
dom.wrapper.removeAttribute( 'data-background-transition' );
dom.viewport.classList.remove( 'reveal-viewport' );
dom.viewport.style.removeProperty( '--slide-width' ); dom.viewport.style.removeProperty( '--slide-width' );
dom.viewport.style.removeProperty( '--slide-height' ); dom.viewport.style.removeProperty( '--slide-height' );
dom.slides.style.removeProperty( 'width' );
dom.slides.style.removeProperty( 'height' );
dom.slides.style.removeProperty( 'zoom' );
dom.slides.style.removeProperty( 'left' );
dom.slides.style.removeProperty( 'top' );
dom.slides.style.removeProperty( 'bottom' );
dom.slides.style.removeProperty( 'right' );
dom.slides.style.removeProperty( 'transform' );
Array.from( dom.wrapper.querySelectorAll( SLIDES_SELECTOR ) ).forEach( slide => {
slide.style.removeProperty( 'display' );
slide.style.removeProperty( 'top' );
slide.removeAttribute( 'hidden' );
slide.removeAttribute( 'aria-hidden' );
} );
} }
/** /**