diff options
author | Hakim El Hattab | 2012-06-06 22:46:21 -0400 |
---|---|---|
committer | Hakim El Hattab | 2012-06-06 22:46:21 -0400 |
commit | 6a03f65e97853226afff31324b26a33d5960a97d (patch) | |
tree | ccb90997e2f1e06f4a2a22b91ce7171075cfb832 /js/reveal.js | |
parent | 2b6c61060b209d7eb58eb0a2fa111caef746f59e (diff) |
include references to previous/current sldie DOM elements in slidechange event
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 } ); } } |