Преглед на файлове

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

Andy Matthews преди 12 години
родител
ревизия
2c78eea0ca
променени са 1 файла, в които са добавени 4 реда и са изтрити 0 реда
  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