diff options
Diffstat (limited to 'js/reveal.js')
-rw-r--r-- | js/reveal.js | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/js/reveal.js b/js/reveal.js index dbe11f5..8ff8e0b 100644 --- a/js/reveal.js +++ b/js/reveal.js @@ -661,11 +661,29 @@ var Reveal = (function(){ clearTimeout( writeURLTimeout ); writeURLTimeout = setTimeout( writeURL, 1500 ); + // Only fire if the slide index is different from before if( indexh !== indexhBefore || indexv !== indexvBefore ) { + // Query all horizontal slides in the deck + var horizontalSlides = document.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR ); + + // Find the previous and current horizontal slides + var previousHorizontalSlide = horizontalSlides[ indexhBefore ], + currentHorizontalSlide = horizontalSlides[ indexh ]; + + // Query all vertical slides inside of the previous and current horizontal slides + var previousVerticalSlides = previousHorizontalSlide.querySelectorAll( 'section' ); + currentVerticalSlides = currentHorizontalSlide.querySelectorAll( 'section' ); + // Dispatch an event notifying observers of the change in slide dispatchEvent( 'slidechanged', { + // Include the current indices in the event 'indexh': indexh, - 'indexv': indexv + 'indexv': indexv, + + // Passes direct references to the slide HTML elements, attempts to find + // a vertical slide and falls back on the horizontal parent + 'previousSlide': previousVerticalSlides[ indexvBefore ] || previousHorizontalSlide, + 'currentSlide': currentVerticalSlides[ indexv ] || currentHorizontalSlide } ); } } |