dispatch events when visible fragment changes ('fragmentshown', 'fragmenthidden') closes #44

This commit is contained in:
Hakim El Hattab
2012-05-31 21:31:28 -04:00
parent 31bbfe9398
commit aaf9da450f
3 changed files with 32 additions and 5 deletions

View File

@@ -654,6 +654,9 @@ var Reveal = (function(){
var verticalFragments = document.querySelectorAll( VERTICAL_SLIDES_SELECTOR + '.present .fragment:not(.visible)' );
if( verticalFragments.length ) {
verticalFragments[0].classList.add( 'visible' );
// Notify subscribers of the change
dispatchEvent( 'fragmentshown', { fragment: verticalFragments[0] } );
return true;
}
}
@@ -662,6 +665,9 @@ var Reveal = (function(){
var horizontalFragments = document.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR + '.present .fragment:not(.visible)' );
if( horizontalFragments.length ) {
horizontalFragments[0].classList.add( 'visible' );
// Notify subscribers of the change
dispatchEvent( 'fragmentshown', { fragment: horizontalFragments[0] } );
return true;
}
}
@@ -681,6 +687,9 @@ var Reveal = (function(){
var verticalFragments = document.querySelectorAll( VERTICAL_SLIDES_SELECTOR + '.present .fragment.visible' );
if( verticalFragments.length ) {
verticalFragments[ verticalFragments.length - 1 ].classList.remove( 'visible' );
// Notify subscribers of the change
dispatchEvent( 'fragmenthidden', { fragment: verticalFragments[0] } );
return true;
}
}
@@ -689,6 +698,9 @@ var Reveal = (function(){
var horizontalFragments = document.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR + '.present .fragment.visible' );
if( horizontalFragments.length ) {
horizontalFragments[ horizontalFragments.length - 1 ].classList.remove( 'visible' );
// Notify subscribers of the change
dispatchEvent( 'fragmenthidden', { fragment: horizontalFragments[0] } );
return true;
}
}