diff --git a/js/impress.js b/js/impress.js index ab69fc1..7841186 100644 --- a/js/impress.js +++ b/js/impress.js @@ -3746,6 +3746,7 @@ var steps = startingState[ root.id ]; var step; while ( step = steps.pop() ) { + // Reset x/y/z in cases where this plugin has changed it. if ( step.relX !== null ) { if ( step.x === null ) { @@ -4002,8 +4003,12 @@ var showSubstep = function( substeps, visible ) { if ( visible.length < substeps.length ) { + for ( var i = 0; i < substeps.length; i++ ) { + substeps[ i ].classList.remove( "substep-active" ); + } var el = substeps[ visible.length ]; el.classList.add( "substep-visible" ); + el.classList.add( "substep-active" ); return el; } }; @@ -4018,6 +4023,16 @@ var hideSubstep = function( visible ) { if ( visible.length > 0 ) { + var current = -1; + for ( var i = 0; i < visible.length; i++ ) { + if ( visible[ i ].classList.contains( "substep-active" ) ) { + current = i; + } + visible[ i ].classList.remove( "substep-active" ); + } + if ( current > 0 ) { + visible[ current - 1 ].classList.add( "substep-active" ); + } var el = visible[ visible.length - 1 ]; el.classList.remove( "substep-visible" ); return el; diff --git a/src/plugins/substep/README.md b/src/plugins/substep/README.md index e4277ff..d15326b 100644 --- a/src/plugins/substep/README.md +++ b/src/plugins/substep/README.md @@ -29,6 +29,12 @@ Example:
Apple
+Classes: + +`substep-active` - The most recent substep in the current step + +`substep-visible` - The most recent and all previous substeps in the current step + Author ------ diff --git a/src/plugins/substep/substep.js b/src/plugins/substep/substep.js index 04370ad..01d5fd5 100644 --- a/src/plugins/substep/substep.js +++ b/src/plugins/substep/substep.js @@ -69,8 +69,12 @@ var showSubstep = function( substeps, visible ) { if ( visible.length < substeps.length ) { + for ( var i = 0; i < substeps.length; i++ ) { + substeps[ i ].classList.remove( "substep-active" ); + } var el = substeps[ visible.length ]; el.classList.add( "substep-visible" ); + el.classList.add( "substep-active" ); return el; } }; @@ -85,6 +89,16 @@ var hideSubstep = function( visible ) { if ( visible.length > 0 ) { + var current = -1; + for ( var i = 0; i < visible.length; i++ ) { + if ( visible[ i ].classList.contains( "substep-active" ) ) { + current = i; + } + visible[ i ].classList.remove( "substep-active" ); + } + if ( current > 0 ) { + visible[ current - 1 ].classList.add( "substep-active" ); + } var el = visible[ visible.length - 1 ]; el.classList.remove( "substep-visible" ); return el;