Support for multiple elements with same data-fragment-index
When multiple elements are specified with the same data-fragment-index, they are all shown or hidden at once.
This commit is contained in:
parent
1219564e05
commit
76fce3b4d9
24
js/reveal.js
24
js/reveal.js
@ -1629,10 +1629,18 @@ var Reveal = (function(){
|
|||||||
var fragments = sortFragments( currentSlide.querySelectorAll( '.fragment:not(.visible)' ) );
|
var fragments = sortFragments( currentSlide.querySelectorAll( '.fragment:not(.visible)' ) );
|
||||||
|
|
||||||
if( fragments.length ) {
|
if( fragments.length ) {
|
||||||
fragments[0].classList.add( 'visible' );
|
// There may be multiple fragments with the same index. We want to display all of them.
|
||||||
|
var nextFragmentIndex = fragments[0].getAttribute( 'data-fragment-index' );
|
||||||
|
|
||||||
|
toArray( fragments ).forEach( function( thisFragment ) {
|
||||||
|
var f = thisFragment.getAttribute( 'data-fragment-index' );
|
||||||
|
if( f === nextFragmentIndex ) {
|
||||||
|
thisFragment.classList.add( 'visible' );
|
||||||
|
|
||||||
// Notify subscribers of the change
|
// Notify subscribers of the change
|
||||||
dispatchEvent( 'fragmentshown', { fragment: fragments[0] } );
|
dispatchEvent( 'fragmentshown', { fragment: thisFragment } );
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
|
||||||
updateControls();
|
updateControls();
|
||||||
return true;
|
return true;
|
||||||
@ -1655,10 +1663,18 @@ var Reveal = (function(){
|
|||||||
var fragments = sortFragments( currentSlide.querySelectorAll( '.fragment.visible' ) );
|
var fragments = sortFragments( currentSlide.querySelectorAll( '.fragment.visible' ) );
|
||||||
|
|
||||||
if( fragments.length ) {
|
if( fragments.length ) {
|
||||||
fragments[ fragments.length - 1 ].classList.remove( 'visible' );
|
// There may be multiple fragments with the same index. We want to display all of them.
|
||||||
|
var prevFragmentIndex = fragments[0].getAttribute( 'data-fragment-index' );
|
||||||
|
|
||||||
|
toArray( fragments ).forEach( function( thisFragment ) {
|
||||||
|
var f = thisFragment.getAttribute( 'data-fragment-index' );
|
||||||
|
if( f === prevFragmentIndex ) {
|
||||||
|
thisFragment.classList.remove( 'visible' );
|
||||||
|
|
||||||
// Notify subscribers of the change
|
// Notify subscribers of the change
|
||||||
dispatchEvent( 'fragmenthidden', { fragment: fragments[ fragments.length - 1 ] } );
|
dispatchEvent( 'fragmenthidden', { fragment: thisFragment } );
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
|
||||||
updateControls();
|
updateControls();
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
Reference in New Issue
Block a user