Explorar o código

Firing custom event based on data-state name. This allows developers to trigger custom javascript code on a per slide basis.

Andy Matthews %!s(int64=12) %!d(string=hai) anos
pai
achega
2c78eea0ca
Modificáronse 1 ficheiros con 4 adicións e 0 borrados
  1. 4 0
      js/reveal.js

+ 4 - 0
js/reveal.js

@@ -501,6 +501,10 @@ var Reveal = (function(){
 		// Apply the new state
 		for( var i = 0, len = state.length; i < len; i++ ) {
 			document.documentElement.classList.add( state[i] );
+			// dispatch custom event
+			var event = document.createEvent("HTMLEvents");
+			event.initEvent(state[i], true, true);
+			document.dispatchEvent(event);
 		}
 
 		// Update progress if enabled