From aaf9da450f51ad3196681cd48e7921c73532ea4d Mon Sep 17 00:00:00 2001 From: Hakim El Hattab Date: Thu, 31 May 2012 21:31:28 -0400 Subject: dispatch events when visible fragment changes ('fragmentshown', 'fragmenthidden') closes #44 --- js/reveal.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'js/reveal.js') diff --git a/js/reveal.js b/js/reveal.js index 729f2f9..d6c5b5b 100644 --- a/js/reveal.js +++ b/js/reveal.js @@ -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; } } -- cgit v1.2.3