From 3a2036e2b20fa13bc92f4fdecc0b17342c4f8204 Mon Sep 17 00:00:00 2001 From: Hakim El Hattab Date: Wed, 17 Oct 2012 00:20:42 -0400 Subject: [PATCH] add 'ready' event (#182) --- README.md | 10 ++++++++++ js/reveal.js | 9 ++++++++- js/reveal.min.js | 10 +++++----- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 91c4e06e..9a7007e8 100644 --- a/README.md +++ b/README.md @@ -154,6 +154,16 @@ Reveal.addEventListener( 'somestate', function() { }, false ); ``` +### Ready event + +The 'ready' event is fired when reveal.js has loaded all (synchronous) dependencies and is ready to start navigating. + +```javascript +Reveal.addEventListener( 'ready', function( event ) { + // event.currentSlide, event.indexh, event.indexv +} ); +``` + ### Slide change event An 'slidechanged' event is fired each time the slide is changed (regardless of state). The event object holds the index values of the current slide as well as a reference to the previous and current slide HTML nodes. diff --git a/js/reveal.js b/js/reveal.js index c1ffb8fe..e53195f6 100644 --- a/js/reveal.js +++ b/js/reveal.js @@ -1,5 +1,5 @@ /*! - * reveal.js 2.1 r33 + * reveal.js 2.1 r34 * http://lab.hakim.se/reveal-js * MIT licensed * @@ -267,6 +267,13 @@ var Reveal = (function(){ // Start auto-sliding if it's enabled cueAutoSlide(); + + // Notify listeners that the presentation is ready + dispatchEvent( 'ready', { + 'indexh': indexh, + 'indexv': indexv, + 'currentSlide': currentSlide + } ); } /** diff --git a/js/reveal.min.js b/js/reveal.min.js index 8f253206..e844a757 100644 --- a/js/reveal.min.js +++ b/js/reveal.min.js @@ -1,5 +1,5 @@ /*! - * reveal.js 2.1 r33 + * reveal.js 2.1 r34 * http://lab.hakim.se/reveal-js * MIT licensed * @@ -18,10 +18,10 @@ f.controlsDown=document.querySelector(".reveal .controls .down");}}function d(){ document.body.style.height="120%";window.addEventListener("load",ad,false);window.addEventListener("orientationchange",ad,false);}}function V(){var al=[],ap=[]; for(var am=0,ak=R.dependencies.length;am