diff options
author | Hakim El Hattab <hakim.elhattab@gmail.com> | 2017-11-21 15:38:44 +0100 |
---|---|---|
committer | Hakim El Hattab <hakim.elhattab@gmail.com> | 2017-11-21 15:38:44 +0100 |
commit | a03e8036289a49f0b4e0b43b1d8547f9ee439d42 (patch) | |
tree | 2bfc4fd1fe8a4b9a02affdeffec05db2857ef6d8 /js | |
parent | 4022cbfe84fc09e2978b5a5b8dc6d3bb693dd178 (diff) | |
download | fosdem-2018-presentation-a03e8036289a49f0b4e0b43b1d8547f9ee439d42.tar fosdem-2018-presentation-a03e8036289a49f0b4e0b43b1d8547f9ee439d42.tar.gz |
make it possible to load/unload slides via the api
Diffstat (limited to 'js')
-rw-r--r-- | js/reveal.js | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/js/reveal.js b/js/reveal.js index 72c4373..bf4194f 100644 --- a/js/reveal.js +++ b/js/reveal.js @@ -2748,10 +2748,10 @@ // Show the horizontal slide if it's within the view distance if( distanceX < viewDistance ) { - showSlide( horizontalSlide ); + loadSlide( horizontalSlide ); } else { - hideSlide( horizontalSlide ); + unloadSlide( horizontalSlide ); } if( verticalSlidesLength ) { @@ -2764,10 +2764,10 @@ distanceY = x === ( indexh || 0 ) ? Math.abs( ( indexv || 0 ) - y ) : Math.abs( y - oy ); if( distanceX + distanceY < viewDistance ) { - showSlide( verticalSlide ); + loadSlide( verticalSlide ); } else { - hideSlide( verticalSlide ); + unloadSlide( verticalSlide ); } } @@ -3166,14 +3166,9 @@ * * @param {HTMLElement} slide Slide to show */ - /** - * Called when the given slide is within the configured view - * distance. Shows the slide element and loads any content - * that is set to load lazily (data-src). - * - * @param {HTMLElement} slide Slide to show - */ - function showSlide( slide ) { + function loadSlide( slide, options ) { + + options = options || {}; // Show the slide element slide.style.display = config.display; @@ -3253,7 +3248,7 @@ background.appendChild( video ); } // Iframes - else if( backgroundIframe ) { + else if( backgroundIframe && options.excludeIframes !== true ) { var iframe = document.createElement( 'iframe' ); iframe.setAttribute( 'allowfullscreen', '' ); iframe.setAttribute( 'mozallowfullscreen', '' ); @@ -3282,12 +3277,12 @@ } /** - * Called when the given slide is moved outside of the - * configured view distance. + * Unloads and hides the given slide. This is called when the + * slide is moved outside of the configured view distance. * * @param {HTMLElement} slide */ - function hideSlide( slide ) { + function unloadSlide( slide ) { // Hide the slide element slide.style.display = 'none'; @@ -5117,6 +5112,10 @@ isAutoSliding: isAutoSliding, isSpeakerNotes: isSpeakerNotes, + // Slide preloading + loadSlide: loadSlide, + unloadSlide: unloadSlide, + // Adds or removes all internal event listeners (such as keyboard) addEventListeners: addEventListeners, removeEventListeners: removeEventListeners, |