From: Andy Matthews Date: Fri, 30 Mar 2012 11:51:54 +0000 (-0500) Subject: Firing custom event based on data-state name. This allows developers to trigger custo... X-Git-Tag: 1.2.0~4 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=2c78eea0ca9496d5eb0e72d92b49aef8b220ef1d;p=reveal.js.git Firing custom event based on data-state name. This allows developers to trigger custom javascript code on a per slide basis. --- diff --git a/js/reveal.js b/js/reveal.js index 1e6ce4d..49c4bc9 100644 --- a/js/reveal.js +++ b/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