viewport tweaks, allow options to be passed when initializing

edit
Hakim El Hattab 2020-04-22 08:59:21 +02:00
parent faaa791019
commit d727509dbc
5 changed files with 29 additions and 18 deletions

2
dist/reveal.es5.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

@ -115,27 +115,18 @@ export default function( revealElement, options ) {
notes = new Notes( Reveal );
/**
* Starts up the presentation if the client is capable.
* Starts up the presentation.
*/
function initialize() {
function initialize( initOptions ) {
// Cache references to key DOM elements
dom.wrapper = revealElement;
dom.slides = revealElement.querySelector( '.slides' );
// Copy options over to our config object
config = { ...defaultConfig, ...options, ...Util.getQueryHash() };
// Compose our config object
config = { ...defaultConfig, ...options, ...initOptions, ...Util.getQueryHash() };
// Embedded decks use the reveal element as their viewport
if( config.embedded === true ) {
revealElement.classList.add( 'reveal-viewport' );
}
// Non-embedded decks cover the full page and use the body
// as their viewport
else {
document.body.classList.add( 'reveal-viewport' );
document.documentElement.classList.add( 'reveal-full-page' );
}
setViewport();
// Force a layout when the whole page, incl fonts, has loaded
window.addEventListener( 'load', layout, false );
@ -147,6 +138,26 @@ export default function( revealElement, options ) {
}
/**
* Encase the presentation in a reveal.js viewport. The
* extent of the viewport differs based on configuration.
*/
function setViewport() {
// Embedded decks use the reveal element as their viewport
if( config.embedded === true ) {
if( revealElement.closest( '.reveal-viewport' ) === null ) {
revealElement.classList.add( 'reveal-viewport' );
}
}
// Full-page decks use the body as their viewport
else {
document.body.classList.add( 'reveal-viewport' );
document.documentElement.classList.add( 'reveal-full-page' );
}
}
/**
* Starts up reveal.js by binding input events and navigating
* to the current URL deeplink if there is one.