Skip to content

Commit

Permalink
additional cleanup when destroying #1145
Browse files Browse the repository at this point in the history
  • Loading branch information
hakimel committed Feb 21, 2022
1 parent 1e0cbe6 commit 5e12c6a
Show file tree
Hide file tree
Showing 10 changed files with 62 additions and 5 deletions.
2 changes: 1 addition & 1 deletion dist/reveal.esm.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/reveal.esm.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/reveal.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/reveal.js.map

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions js/controllers/backgrounds.js
Original file line number Diff line number Diff line change
Expand Up @@ -394,4 +394,10 @@ export default class Backgrounds {

}

destroy() {

this.element.remove();

}

}
6 changes: 6 additions & 0 deletions js/controllers/focus.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ export default class Focus {

}

destroy() {

this.Reveal.getRevealElement().classList.remove( 'focused' );

}

onRevealPointerDown( event ) {

this.focus();
Expand Down
6 changes: 6 additions & 0 deletions js/controllers/notes.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,10 @@ export default class Notes {

}

destroy() {

this.element.remove();

}

}
5 changes: 5 additions & 0 deletions js/controllers/progress.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,5 +101,10 @@ export default class Progress {

}

destroy() {

this.element.remove();

}

}
6 changes: 6 additions & 0 deletions js/controllers/slidenumber.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,10 @@ export default class SlideNumber {

}

destroy() {

this.element.remove();

}

}
30 changes: 29 additions & 1 deletion js/reveal.js
Original file line number Diff line number Diff line change
Expand Up @@ -563,9 +563,14 @@ export default function( revealElement, options ) {
disablePreviewLinks();

// Destroy controllers
notes.destroy();
focus.destroy();
plugins.destroy();
pointer.destroy();
controls.destroy();
progress.destroy();
backgrounds.destroy();
slideNumber.destroy();

// Remove event listeners
document.removeEventListener( 'fullscreenchange', onFullscreenChange );
Expand All @@ -575,12 +580,35 @@ export default function( revealElement, options ) {
window.removeEventListener( 'load', layout, false );

// 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' );

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-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' );
} );

}

/**
Expand Down

0 comments on commit 5e12c6a

Please sign in to comment.