mirror of
https://github.com/Noratrieb/slides.git
synced 2026-01-16 09:25:06 +01:00
include references to previous/current sldie DOM elements in slidechange event
This commit is contained in:
parent
2b6c61060b
commit
6a03f65e97
4 changed files with 32 additions and 14 deletions
20
js/reveal.js
20
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
|
||||
} );
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue