add data-fragment=<index> attribute to slide <sections>

This commit is contained in:
Hakim El Hattab
2020-01-15 11:37:37 +01:00
parent 76187bc666
commit ac50753521
2 changed files with 27 additions and 0 deletions

View File

@ -4751,6 +4751,8 @@
if( fragments.length ) {
var maxIndex = 0;
if( typeof index !== 'number' ) {
var currentFragment = sortFragments( currentSlide.querySelectorAll( '.fragment.visible' ) ).pop();
if( currentFragment ) {
@ -4764,6 +4766,8 @@
i = parseInt( el.getAttribute( 'data-fragment-index' ), 10 );
}
maxIndex = Math.max( maxIndex, i );
// Visible fragments
if( i <= index ) {
if( !el.classList.contains( 'visible' ) ) changedFragments.shown.push( el );
@ -4787,6 +4791,13 @@
} );
// Write the current fragment index to the slide <section>.
// This can be used by end users to apply styles based on
// the current fragment index.
index = typeof index === 'number' ? index : -1;
index = Math.max( Math.min( index, maxIndex ), -1 );
currentSlide.setAttribute( 'data-fragment', index );
}
}