aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorHakim El Hattab <hakim.elhattab@gmail.com>2020-04-22 08:59:21 +0200
committerHakim El Hattab <hakim.elhattab@gmail.com>2020-04-22 08:59:21 +0200
commitd727509dbcc1e6566818a8ada5b40b0cdccd42ff (patch)
tree5e9ffa562bcb5788547ee66667fb6ab5e8b5f97e /js
parentfaaa79101996bf996ad3888960cfcd5303c9b5b0 (diff)
downloadfosdem-2021-minimalism-presentation-d727509dbcc1e6566818a8ada5b40b0cdccd42ff.tar
fosdem-2021-minimalism-presentation-d727509dbcc1e6566818a8ada5b40b0cdccd42ff.tar.gz
viewport tweaks, allow options to be passed when initializing
Diffstat (limited to 'js')
-rw-r--r--js/reveal.js39
1 files changed, 25 insertions, 14 deletions
diff --git a/js/reveal.js b/js/reveal.js
index 50f8dbd..6712529 100644
--- a/js/reveal.js
+++ b/js/reveal.js
@@ -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 );
@@ -148,6 +139,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.
*/