diff --git a/js/reveal.js b/js/reveal.js index c1f50b8..dbe11f5 100644 --- a/js/reveal.js +++ b/js/reveal.js @@ -610,16 +610,19 @@ var Reveal = (function(){ * Updates the visual slides to represent the currently * set indices. */ - function slide() { + function slide( h, v ) { // Remember the state before this slide var stateBefore = state.concat(); // Reset the state array state.length = 0; + var indexhBefore = indexh, + indexvBefore = indexv; + // Activate and transition to the new slide - indexh = updateSlides( HORIZONTAL_SLIDES_SELECTOR, indexh ); - indexv = updateSlides( VERTICAL_SLIDES_SELECTOR, indexv ); + indexh = updateSlides( HORIZONTAL_SLIDES_SELECTOR, h === undefined ? indexh : h ); + indexv = updateSlides( VERTICAL_SLIDES_SELECTOR, v === undefined ? indexv : v ); // Apply the new state stateLoop: for( var i = 0, len = state.length; i < len; i++ ) { @@ -658,11 +661,13 @@ var Reveal = (function(){ clearTimeout( writeURLTimeout ); writeURLTimeout = setTimeout( writeURL, 1500 ); - // Dispatch an event notifying observers of the change in slide - dispatchEvent( 'slidechanged', { - 'indexh': indexh, - 'indexv': indexv - } ); + if( indexh !== indexhBefore || indexv !== indexvBefore ) { + // Dispatch an event notifying observers of the change in slide + dispatchEvent( 'slidechanged', { + 'indexh': indexh, + 'indexv': indexv + } ); + } } /** @@ -814,40 +819,31 @@ var Reveal = (function(){ * @param {Number} v The vertical index of the slide to show */ function navigateTo( h, v ) { - indexh = h === undefined ? indexh : h; - indexv = v === undefined ? indexv : v; - - slide(); + slide( h, v ); } function navigateLeft() { // Prioritize hiding fragments if( overviewIsActive() || previousFragment() === false ) { - indexh --; - indexv = 0; - slide(); + slide( indexh - 1, 0 ); } } function navigateRight() { // Prioritize revealing fragments if( overviewIsActive() || nextFragment() === false ) { - indexh ++; - indexv = 0; - slide(); + slide( indexh + 1, 0 ); } } function navigateUp() { // Prioritize hiding fragments if( overviewIsActive() || previousFragment() === false ) { - indexv --; - slide(); + slide( indexh, indexv - 1 ); } } function navigateDown() { // Prioritize revealing fragments if( overviewIsActive() || nextFragment() === false ) { - indexv ++; - slide(); + slide( indexh, indexv + 1 ); } } diff --git a/js/reveal.min.js b/js/reveal.min.js index 37f6cbe..065cd2f 100644 --- a/js/reveal.min.js +++ b/js/reveal.min.js @@ -42,9 +42,10 @@ c=this.getAttribute("data-index-v");b();}}function U(W,Y){var aa=Array.prototype if(Y<0){Y=ab+Y;}}Y=Math.max(Math.min(Y,ab-1),0);for(var Z=0;Z3?"none":"block"; }aa[Z].classList.remove("past");aa[Z].classList.remove("present");aa[Z].classList.remove("future");if(ZY){aa[Z].classList.add("future"); }}if(V.querySelector("section")){aa[Z].classList.add("stack");}}aa[Y].classList.add("present");var X=aa[Y].getAttribute("data-state");if(X){T=T.concat(X.split(" ")); -}}else{Y=0;}return Y;}function b(){var Y=T.concat();T.length=0;k=U(j,k);c=U(a,c);stateLoop:for(var X=0,V=T.length;X0,right:k0,down:c0||c>0){V+=k; @@ -53,8 +54,8 @@ continue stateLoop;}}document.documentElement.classList.add(T[X]);o(T[X]);}while o("fragmentshown",{fragment:W[0]});return true;}}else{var V=document.querySelectorAll(j+".present .fragment:not(.visible)");if(V.length){V[0].classList.add("visible"); o("fragmentshown",{fragment:V[0]});return true;}}return false;}function G(){if(document.querySelector(a+".present")){var W=document.querySelectorAll(a+".present .fragment.visible"); if(W.length){W[W.length-1].classList.remove("visible");o("fragmenthidden",{fragment:W[0]});return true;}}else{var V=document.querySelectorAll(j+".present .fragment.visible"); -if(V.length){V[V.length-1].classList.remove("visible");o("fragmenthidden",{fragment:V[0]});return true;}}return false;}function F(W,V){k=W===undefined?k:W; -c=V===undefined?c:V;b();}function w(){if(O()||G()===false){k--;c=0;b();}}function i(){if(O()||s()===false){k++;c=0;b();}}function r(){if(O()||G()===false){c--; -b();}}function A(){if(O()||s()===false){c++;b();}}function N(){if(G()===false){if(f().up){r();}else{var V=document.querySelector(".reveal .slides>section.past:nth-child("+k+")"); -if(V){c=(V.querySelectorAll("section").length+1)||0;k--;b();}}}}function u(){if(s()===false){f().down?A():i();}}function M(){if(O()){Q();}else{B();}}return{initialize:h,navigateTo:F,navigateLeft:w,navigateRight:i,navigateUp:r,navigateDown:A,toggleOverview:M,addEventListeners:z,removeEventListeners:K,addEventListener:function(W,X,V){(d.wrapper||document.querySelector(".reveal")).addEventListener(W,X,V); +if(V.length){V[V.length-1].classList.remove("visible");o("fragmenthidden",{fragment:V[0]});return true;}}return false;}function F(W,V){b(W,V);}function w(){if(O()||G()===false){b(k-1,0); +}}function i(){if(O()||s()===false){b(k+1,0);}}function r(){if(O()||G()===false){b(k,c-1);}}function A(){if(O()||s()===false){b(k,c+1);}}function N(){if(G()===false){if(f().up){r(); +}else{var V=document.querySelector(".reveal .slides>section.past:nth-child("+k+")");if(V){c=(V.querySelectorAll("section").length+1)||0;k--;b();}}}}function u(){if(s()===false){f().down?A():i(); +}}function M(){if(O()){Q();}else{B();}}return{initialize:h,navigateTo:F,navigateLeft:w,navigateRight:i,navigateUp:r,navigateDown:A,toggleOverview:M,addEventListeners:z,removeEventListeners:K,addEventListener:function(W,X,V){(d.wrapper||document.querySelector(".reveal")).addEventListener(W,X,V); },removeEventListener:function(W,X,V){(d.wrapper||document.querySelector(".reveal")).removeEventListener(W,X,V);}};})(); \ No newline at end of file