1
0
Fork 0

rewrite fragment index attributes to leave no gaps between fragments

This commit is contained in:
Hakim El Hattab 2013-11-21 09:16:40 -05:00
parent 60a74ebfa3
commit 2faae3d95b
2 changed files with 17 additions and 15 deletions

View File

@ -1045,16 +1045,14 @@ var Reveal = (function(){
var a = toArray( fragments );
a.forEach( function( el, idx ) {
if( !el.hasAttribute( 'data-fragment-index' ) ) {
el.setAttribute( 'data-fragment-index', idx );
}
} );
a.sort( function( l, r ) {
return l.getAttribute( 'data-fragment-index' ) - r.getAttribute( 'data-fragment-index');
} );
a.forEach( function( el, idx ) {
el.setAttribute( 'data-fragment-index', idx );
} );
return a;
}
@ -2309,14 +2307,12 @@ var Reveal = (function(){
toArray( fragments ).forEach( function( element, i ) {
// Hidden fragments
if( i > index ) {
if( element.classList.contains( 'visible' ) ) fragmentsHidden.push( element );
element.classList.remove( 'visible' );
element.classList.remove( 'current-fragment' );
if( element.hasAttribute( 'data-fragment-index' ) ) {
i = parseInt( element.getAttribute( 'data-fragment-index' ), 10 );
}
// Visible fragments
else {
if( i <= index ) {
if( !element.classList.contains( 'visible' ) ) fragmentsShown.push( element );
element.classList.add( 'visible' );
element.classList.remove( 'current-fragment' );
@ -2325,6 +2321,12 @@ var Reveal = (function(){
element.classList.add( 'current-fragment' );
}
}
// Hidden fragments
else {
if( element.classList.contains( 'visible' ) ) fragmentsHidden.push( element );
element.classList.remove( 'visible' );
element.classList.remove( 'current-fragment' );
}
} );

6
js/reveal.min.js vendored

File diff suppressed because one or more lines are too long