Bläddra i källkod

add 'ready' event (#182)

Hakim El Hattab 11 år sedan
förälder
incheckning
3a2036e2b2
3 ändrade filer med 23 tillägg och 6 borttagningar
  1. 10 0
      README.md
  2. 8 1
      js/reveal.js
  3. 5 5
      js/reveal.min.js

+ 10 - 0
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.

+ 8 - 1
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
+		} );
 	}
 
 	/**

+ 5 - 5
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<ak;am++){var an=R.dependencies[am];if(!an.condition||an.condition()){if(an.async){ap.push(an.src);}else{al.push(an.src);
 }if(typeof an.callback==="function"){head.ready(an.src.match(/([\w\d_\-]*)\.?[^\\\/]*$/i)[0],an.callback);}}}function ao(){head.js.apply(null,ap);H();}if(al.length){head.ready(ao);
-head.js.apply(null,al);}else{ao();}}function H(){E();K();J();O();}function K(){if(T===false){R.transition="linear";}if(R.controls&&f.controls){f.controls.style.display="block";
-}if(R.progress&&f.progress){f.progress.style.display="block";}if(R.transition!=="default"){f.wrapper.classList.add(R.transition);}if(R.mouseWheel){document.addEventListener("DOMMouseScroll",o,false);
-document.addEventListener("mousewheel",o,false);}if(R.rollingLinks){N();}if(R.theme&&f.theme){var am=f.theme.getAttribute("href");var ak=/[^\/]*?(?=\.css)/;
-var al=am.match(ak)[0];if(R.theme!==al){am=am.replace(ak,R.theme);f.theme.setAttribute("href",am);}}}function E(){document.addEventListener("touchstart",A,false);
+head.js.apply(null,al);}else{ao();}}function H(){E();K();J();O();r("ready",{indexh:m,indexv:e,currentSlide:G});}function K(){if(T===false){R.transition="linear";
+}if(R.controls&&f.controls){f.controls.style.display="block";}if(R.progress&&f.progress){f.progress.style.display="block";}if(R.transition!=="default"){f.wrapper.classList.add(R.transition);
+}if(R.mouseWheel){document.addEventListener("DOMMouseScroll",o,false);document.addEventListener("mousewheel",o,false);}if(R.rollingLinks){N();}if(R.theme&&f.theme){var am=f.theme.getAttribute("href");
+var ak=/[^\/]*?(?=\.css)/;var al=am.match(ak)[0];if(R.theme!==al){am=am.replace(ak,R.theme);f.theme.setAttribute("href",am);}}}function E(){document.addEventListener("touchstart",A,false);
 document.addEventListener("touchmove",af,false);document.addEventListener("touchend",W,false);window.addEventListener("hashchange",w,false);if(R.keyboard){document.addEventListener("keydown",ah,false);
 }if(R.controls&&f.controls){f.controlsLeft.addEventListener("click",q(B),false);f.controlsRight.addEventListener("click",q(j),false);f.controlsUp.addEventListener("click",q(u),false);
 f.controlsDown.addEventListener("click",q(F),false);}}function U(){document.removeEventListener("keydown",ah,false);document.removeEventListener("touchstart",A,false);