respect original dom order of fragments with no explicit index
This commit is contained in:
parent
2faae3d95b
commit
c33aa66666
2 changed files with 13 additions and 3 deletions
10
js/reveal.js
10
js/reveal.js
|
@ -1045,10 +1045,20 @@ var Reveal = (function(){
|
||||||
|
|
||||||
var a = toArray( fragments );
|
var a = toArray( fragments );
|
||||||
|
|
||||||
|
// Elements that do not have an explicit `data-fragment-index`
|
||||||
|
// are given one which matches their order in the DOM
|
||||||
|
a.forEach( function( el, idx ) {
|
||||||
|
if( !el.hasAttribute( 'data-fragment-index' ) ) {
|
||||||
|
el.setAttribute( 'data-fragment-index', idx );
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
|
||||||
a.sort( function( l, r ) {
|
a.sort( function( l, r ) {
|
||||||
return l.getAttribute( 'data-fragment-index' ) - r.getAttribute( 'data-fragment-index');
|
return l.getAttribute( 'data-fragment-index' ) - r.getAttribute( 'data-fragment-index');
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
// Set the indices to match the order of the sorted fragments,
|
||||||
|
// ensures that we're 0-indexed and have no gaps
|
||||||
a.forEach( function( el, idx ) {
|
a.forEach( function( el, idx ) {
|
||||||
el.setAttribute( 'data-fragment-index', idx );
|
el.setAttribute( 'data-fragment-index', idx );
|
||||||
} );
|
} );
|
||||||
|
|
6
js/reveal.min.js
vendored
6
js/reveal.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue