diff --git a/js/reveal.js b/js/reveal.js index f797084..1c0e69d 100644 --- a/js/reveal.js +++ b/js/reveal.js @@ -2671,28 +2671,6 @@ layout(); - // Apply the new state - stateLoop: for( var i = 0, len = state.length; i < len; i++ ) { - // Check if this state existed on the previous slide. If it - // did, we will avoid adding it repeatedly - for( var j = 0; j < stateBefore.length; j++ ) { - if( stateBefore[j] === state[i] ) { - stateBefore.splice( j, 1 ); - continue stateLoop; - } - } - - document.documentElement.classList.add( state[i] ); - - // Dispatch custom event matching the state's name - dispatchEvent( state[i] ); - } - - // Clean up the remains of the previous state - while( stateBefore.length ) { - document.documentElement.classList.remove( stateBefore.pop() ); - } - // Update the overview if it's currently active if( isOverview() ) { updateOverview(); @@ -2741,6 +2719,28 @@ } } + // Apply the new state + stateLoop: for( var i = 0, len = state.length; i < len; i++ ) { + // Check if this state existed on the previous slide. If it + // did, we will avoid adding it repeatedly + for( var j = 0; j < stateBefore.length; j++ ) { + if( stateBefore[j] === state[i] ) { + stateBefore.splice( j, 1 ); + continue stateLoop; + } + } + + document.documentElement.classList.add( state[i] ); + + // Dispatch custom event matching the state's name + dispatchEvent( state[i] ); + } + + // Clean up the remains of the previous state + while( stateBefore.length ) { + document.documentElement.classList.remove( stateBefore.pop() ); + } + if( slideChanged ) { dispatchEvent( 'slidechanged', { 'indexh': indexh, diff --git a/test/test-state.html b/test/test-state.html new file mode 100644 index 0000000..e6ae423 --- /dev/null +++ b/test/test-state.html @@ -0,0 +1,139 @@ + + + + + + + reveal.js - Test State + + + + + + + +
+
+ + + + + + + + + +