From 64e72781b4d576a2a32e7c4b3e1692d03a182c7d Mon Sep 17 00:00:00 2001
From: Hakim El Hattab <hakim.elhattab@gmail.com>
Date: Wed, 28 Jan 2015 08:33:50 +0100
Subject: [PATCH] ensure overview indices are up to date if a slide moves

---
 js/reveal.js | 27 +++++++++------------------
 1 file changed, 9 insertions(+), 18 deletions(-)

diff --git a/js/reveal.js b/js/reveal.js
index 37c6831..9ed7b7e 100644
--- a/js/reveal.js
+++ b/js/reveal.js
@@ -1664,24 +1664,11 @@
 			// that the same scaling is applied
 			dom.slides.appendChild( dom.background );
 
-			// Bind events so that clicking on a slide navigates to it
-			toArray( dom.wrapper.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR ) ).forEach( function( hslide, h ) {
-
-				hslide.setAttribute( 'data-index-h', h );
-
-				if( hslide.classList.contains( 'stack' ) ) {
-					toArray( hslide.querySelectorAll( 'section' ) ).forEach( function( vslide, v ) {
-
-						vslide.setAttribute( 'data-index-h', h );
-						vslide.setAttribute( 'data-index-v', v );
-						vslide.addEventListener( 'click', onOverviewSlideClicked, true );
-
-					} );
-				}
-				else {
-					hslide.addEventListener( 'click', onOverviewSlideClicked, true );
+			// Clicking on an overview slide navigates to it
+			toArray( dom.wrapper.querySelectorAll( SLIDES_SELECTOR ) ).forEach( function( slide ) {
+				if( !slide.classList.contains( 'stack' ) ) {
+					slide.addEventListener( 'click', onOverviewSlideClicked, true );
 				}
-
 			} );
 
 			updateSlidesVisibility();
@@ -1718,11 +1705,15 @@
 
 		// Layout slides
 		toArray( dom.wrapper.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR ) ).forEach( function( hslide, h ) {
+			hslide.setAttribute( 'data-index-h', h );
 			transformElement( hslide, 'translate3d(' + ( h * slideWidth ) + 'px, 0, 0)' );
 
 			if( hslide.classList.contains( 'stack' ) ) {
 
 				toArray( hslide.querySelectorAll( 'section' ) ).forEach( function( vslide, v ) {
+					vslide.setAttribute( 'data-index-h', h );
+					vslide.setAttribute( 'data-index-v', v );
+
 					transformElement( vslide, 'translate3d(0, ' + ( v * slideHeight ) + 'px, 0)' );
 				} );
 
@@ -1997,7 +1988,7 @@
 
 		// If no vertical index is specified and the upcoming slide is a
 		// stack, resume at its previous vertical index
-		if( v === undefined ) {
+		if( v === undefined && !isOverview() ) {
 			v = getPreviousVerticalIndex( horizontalSlides[ h ] );
 		}
 
-- 
GitLab