diff options
author | Hakim El Hattab <hakim.elhattab@gmail.com> | 2014-04-27 14:54:23 +0200 |
---|---|---|
committer | Hakim El Hattab <hakim.elhattab@gmail.com> | 2014-04-27 14:54:23 +0200 |
commit | 902e36c0228478083d9f2ef487c12f9de401d404 (patch) | |
tree | 186c661d71450e9a2f9f758eab462fda94c27cec /js | |
parent | eea437f4be92bafbe96d5276233d4fdff7b5f814 (diff) | |
download | perl-software-in-gnu-guix-902e36c0228478083d9f2ef487c12f9de401d404.tar perl-software-in-gnu-guix-902e36c0228478083d9f2ef487c12f9de401d404.tar.gz |
break showing/hiding of slides into separate methods
Diffstat (limited to 'js')
-rw-r--r-- | js/reveal.js | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/js/reveal.js b/js/reveal.js index 55642e2..2c87c87 100644 --- a/js/reveal.js +++ b/js/reveal.js @@ -2029,11 +2029,10 @@ var Reveal = (function(){ // Show the horizontal slide if it's within the view distance if( distanceX < viewDistance ) { - horizontalSlide.style.display = 'block'; - loadSlide( horizontalSlide ); + showSlide( horizontalSlide ); } else { - horizontalSlide.style.display = 'none'; + hideSlide( horizontalSlide ); } if( verticalSlidesLength ) { @@ -2046,11 +2045,10 @@ var Reveal = (function(){ distanceY = x === indexh ? Math.abs( indexv - y ) : Math.abs( y - oy ); if( distanceX + distanceY < viewDistance ) { - verticalSlide.style.display = 'block'; - loadSlide( verticalSlide ); + showSlide( verticalSlide ); } else { - verticalSlide.style.display = 'none'; + hideSlide( verticalSlide ); } } @@ -2275,10 +2273,13 @@ var Reveal = (function(){ } /** - * Loads any content that is set to load lazily (data-src) - * inside of the given slide. + * 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). */ - function loadSlide( slide ) { + function showSlide( slide ) { + + slide.style.display = 'block'; // Media elements with data-src attributes toArray( slide.querySelectorAll( 'img[data-src], video[data-src], audio[data-src], iframe[data-src]' ) ).forEach( function( element ) { @@ -2306,6 +2307,16 @@ var Reveal = (function(){ } /** + * Called when the given slide is moved outside of the + * configured view distance. + */ + function hideSlide( slide ) { + + slide.style.display = 'none'; + + } + + /** * Determine what available routes there are for navigation. * * @return {Object} containing four booleans: left/right/up/down |