Skip to content

Commit 60a74eb

Browse files
committed
fragments are now zero-indexed
1 parent 9d0ac52 commit 60a74eb

File tree

3 files changed

+24
-24
lines changed

3 files changed

+24
-24
lines changed

js/reveal.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,7 +1047,7 @@ var Reveal = (function(){
10471047

10481048
a.forEach( function( el, idx ) {
10491049
if( !el.hasAttribute( 'data-fragment-index' ) ) {
1050-
el.setAttribute( 'data-fragment-index', idx + 1 );
1050+
el.setAttribute( 'data-fragment-index', idx );
10511051
}
10521052
} );
10531053

@@ -2261,7 +2261,7 @@ var Reveal = (function(){
22612261
var hasFragments = currentSlide.querySelectorAll( '.fragment' ).length > 0;
22622262
if( hasFragments ) {
22632263
var visibleFragments = currentSlide.querySelectorAll( '.fragment.visible' );
2264-
f = visibleFragments.length;
2264+
f = visibleFragments.length - 1;
22652265
}
22662266
}
22672267

@@ -2273,7 +2273,7 @@ var Reveal = (function(){
22732273
* Navigate to the specified slide fragment.
22742274
*
22752275
* @param {Number} index The index of the fragment that
2276-
* should be shown, 1-based, 0 means all are invisible
2276+
* should be shown, -1 means all are invisible
22772277
* @param {Number} offset Integer offset to apply to the
22782278
* fragment index
22792279
*
@@ -2292,10 +2292,10 @@ var Reveal = (function(){
22922292
var lastVisibleFragment = sortFragments( currentSlide.querySelectorAll( '.fragment.visible' ) ).pop();
22932293

22942294
if( lastVisibleFragment ) {
2295-
index = parseInt( lastVisibleFragment.getAttribute( 'data-fragment-index' ) || 1, 10 );
2295+
index = parseInt( lastVisibleFragment.getAttribute( 'data-fragment-index' ) || 0, 10 );
22962296
}
22972297
else {
2298-
index = 0;
2298+
index = -1;
22992299
}
23002300
}
23012301

@@ -2309,8 +2309,14 @@ var Reveal = (function(){
23092309

23102310
toArray( fragments ).forEach( function( element, i ) {
23112311

2312+
// Hidden fragments
2313+
if( i > index ) {
2314+
if( element.classList.contains( 'visible' ) ) fragmentsHidden.push( element );
2315+
element.classList.remove( 'visible' );
2316+
element.classList.remove( 'current-fragment' );
2317+
}
23122318
// Visible fragments
2313-
if( i < index ) {
2319+
else {
23142320
if( !element.classList.contains( 'visible' ) ) fragmentsShown.push( element );
23152321
element.classList.add( 'visible' );
23162322
element.classList.remove( 'current-fragment' );
@@ -2319,12 +2325,6 @@ var Reveal = (function(){
23192325
element.classList.add( 'current-fragment' );
23202326
}
23212327
}
2322-
// Hidden fragments
2323-
else {
2324-
if( element.classList.contains( 'visible' ) ) fragmentsHidden.push( element );
2325-
element.classList.remove( 'visible' );
2326-
element.classList.remove( 'current-fragment' );
2327-
}
23282328

23292329

23302330
} );

0 commit comments

Comments
 (0)