From 68f8c9361e452b1c9740d9f6c72327ac7acd60c4 Mon Sep 17 00:00:00 2001 From: Hakim El Hattab Date: Wed, 2 Jan 2013 09:14:28 -0500 Subject: [PATCH] fix issue with auto-advance (closes #273) --- js/reveal.js | 5 +++-- js/reveal.min.js | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/js/reveal.js b/js/reveal.js index 70e25392..4574e25e 100644 --- a/js/reveal.js +++ b/js/reveal.js @@ -958,7 +958,8 @@ var Reveal = (function(){ var slideAutoSlide = slides[index].getAttribute( 'data-autoslide' ); if( slideAutoSlide ) { autoSlide = parseInt( slideAutoSlide, 10 ); - } else { + } + else { autoSlide = config.autoSlide; } @@ -1165,7 +1166,7 @@ var Reveal = (function(){ // If this is a vertical slide, grab the vertical index if( isVertical ) { - v = Math.max( toArray( slide.parentNode.children ).indexOf( slide ), 0 ); + v = Math.max( toArray( slide.parentNode.querySelectorAll( 'section' ) ).indexOf( slide ), 0 ); } } diff --git a/js/reveal.min.js b/js/reveal.min.js index 0b81b8f9..b41b8c12 100644 --- a/js/reveal.min.js +++ b/js/reveal.min.js @@ -1,8 +1,8 @@ /*! - * reveal.js 2.2 (2012-11-27, 08:44) + * reveal.js 2.2 (2013-01-02, 09:12) * http://lab.hakim.se/reveal-js * MIT licensed * * Copyright (C) 2011-2012 Hakim El Hattab, http://hakim.se */ -var Reveal=function(){"use strict";function y(e){if(!h&&!c){document.body.setAttribute("class","no-transforms");return}window.addEventListener("load",P,!1),C(r,e),w(),E()}function b(){l.theme=document.querySelector("#theme"),l.wrapper=document.querySelector(".reveal"),l.slides=document.querySelector(".reveal .slides");if(!l.wrapper.querySelector(".progress")&&r.progress){var e=document.createElement("div");e.classList.add("progress"),e.innerHTML="",l.wrapper.appendChild(e)}if(!l.wrapper.querySelector(".controls")&&r.controls){var t=document.createElement("aside");t.classList.add("controls"),t.innerHTML='',l.wrapper.appendChild(t)}if(!l.wrapper.querySelector(".state-background")){var n=document.createElement("div");n.classList.add("state-background"),l.wrapper.appendChild(n)}if(!l.wrapper.querySelector(".pause-overlay")){var i=document.createElement("div");i.classList.add("pause-overlay"),l.wrapper.appendChild(i)}l.progress=document.querySelector(".reveal .progress"),l.progressbar=document.querySelector(".reveal .progress span"),r.controls&&(l.controls=document.querySelector(".reveal .controls"),l.controlsLeft=k(document.querySelectorAll(".navigate-left")),l.controlsRight=k(document.querySelectorAll(".navigate-right")),l.controlsUp=k(document.querySelectorAll(".navigate-up")),l.controlsDown=k(document.querySelectorAll(".navigate-down")),l.controlsPrev=k(document.querySelectorAll(".navigate-prev")),l.controlsNext=k(document.querySelectorAll(".navigate-next")))}function w(){navigator.userAgent.match(/(iphone|ipod)/i)&&(document.documentElement.style.overflow="scroll",document.body.style.height="120%",window.addEventListener("load",M,!1),window.addEventListener("orientationchange",M,!1))}function E(){function o(){t.length&&head.js.apply(null,t),S()}var e=[],t=[];for(var n=0,i=r.dependencies.length;n'+i.innerHTML+"")}}}function P(){if(r.center){var t=k(document.querySelectorAll(e)),n=-l.wrapper.offsetHeight/2;for(var i=0,s=t.length;i3?"none":"block"}n[o].classList.remove("past"),n[o].classList.remove("present"),n[o].classList.remove("future"),ot&&n[o].classList.add("future"),u.querySelector("section")&&n[o].classList.add("stack")}n[t].classList.add("present");var l=n[t].getAttribute("data-state");l&&(f=f.concat(l.split(" ")));var c=n[t].getAttribute("data-autoslide");c?i=parseInt(c,10):i=r.autoSlide}else t=0;return t}function J(){if(r.progress&&l.progress){var n=k(document.querySelectorAll(t)),i=document.querySelectorAll(e+":not(.stack)").length,s=0;e:for(var o=0;o0,right:s0,down:o0||o>0)t+=s;o>0&&(t+="/"+o)}window.location.hash=t}}}function Z(e){var n=s,r=o;if(e){var i=!!e.parentNode.nodeName.match(/section/gi),u=i?e.parentNode:e,a=k(document.querySelectorAll(t));n=Math.max(a.indexOf(u),0),i&&(r=Math.max(k(e.parentNode.children).indexOf(e),0))}return{h:n,v:r}}function et(){if(document.querySelector(n+".present")){var e=document.querySelectorAll(n+".present .fragment:not(.visible)");if(e.length)return e[0].classList.add("visible"),_("fragmentshown",{fragment:e[0]}),!0}else{var r=document.querySelectorAll(t+".present .fragment:not(.visible)");if(r.length)return r[0].classList.add("visible"),_("fragmentshown",{fragment:r[0]}),!0}return!1}function tt(){if(document.querySelector(n+".present")){var e=document.querySelectorAll(n+".present .fragment.visible");if(e.length)return e[e.length-1].classList.remove("visible"),_("fragmenthidden",{fragment:e[e.length-1]}),!0}else{var r=document.querySelectorAll(t+".present .fragment.visible");if(r.length)return r[r.length-1].classList.remove("visible"),_("fragmenthidden",{fragment:r[r.length-1]}),!0}return!1}function nt(){clearTimeout(d),i&&(d=setTimeout(at,i))}function rt(){(Q().left&&q()||tt()===!1)&&V(s-1)}function it(){(Q().right&&q()||et()===!1)&&V(s+1)}function st(){(Q().up&&q()||tt()===!1)&&V(s,o-1)}function ot(){(Q().down&&q()||et()===!1)&&V(s,o+1)}function ut(){if(tt()===!1)if(Q().up)st();else{var e=document.querySelector(t+".past:nth-child("+s+")");e&&(o=e.querySelectorAll("section").length+1||undefined,s--,V())}}function at(){et()===!1&&(Q().down?ot():it()),nt()}function ft(e){var t=document.activeElement,n=!(!document.activeElement||!document.activeElement.type&&!document.activeElement.href&&document.activeElement.contentEditable==="inherit");if(n||e.shiftKey||e.altKey||e.ctrlKey||e.metaKey)return;var r=!0;switch(e.keyCode){case 80:case 33:ut();break;case 78:case 34:at();break;case 72:case 37:rt();break;case 76:case 39:it();break;case 75:case 38:st();break;case 74:case 40:ot();break;case 36:V(0);break;case 35:V(Number.MAX_VALUE);break;case 32:q()?F():at();break;case 13:q()?F():r=!1;break;case 66:case 190:W();break;case 70:R();break;default:r=!1}r?e.preventDefault():e.keyCode===27&&c&&(I(),e.preventDefault()),nt()}function lt(e){g.startX=e.touches[0].clientX,g.startY=e.touches[0].clientY,g.startCount=e.touches.length,e.touches.length===2&&r.overview&&(g.startSpan=A({x:e.touches[1].clientX,y:e.touches[1].clientY},{x:g.startX,y:g.startY}))}function ct(e){if(!g.handled){var t=e.touches[0].clientX,n=e.touches[0].clientY;if(e.touches.length===2&&g.startCount===2&&r.overview){var i=A({x:e.touches[1].clientX,y:e.touches[1].clientY},{x:g.startX,y:g.startY});Math.abs(g.startSpan-i)>g.threshold&&(g.handled=!0,ig.threshold&&Math.abs(s)>Math.abs(o)?(g.handled=!0,rt()):s<-g.threshold&&Math.abs(s)>Math.abs(o)?(g.handled=!0,it()):o>g.threshold?(g.handled=!0,st()):o<-g.threshold&&(g.handled=!0,ot()),e.preventDefault()}}else navigator.userAgent.match(/android/gi)&&e.preventDefault()}function ht(e){g.handled=!1}function pt(e){clearTimeout(p),p=setTimeout(function(){var t=e.detail||-e.wheelDelta;t>0?at():ut()},100)}function dt(e){var n=k(document.querySelectorAll(t)).length,r=Math.floor(e.clientX/l.wrapper.offsetWidth*n);V(r)}function vt(e){G()}function mt(e){P()}function gt(e){if(q()){e.preventDefault(),F();var t=e.target;while(t&&!t.nodeName.match(/section/gi))t=t.parentNode;if(t.nodeName.match(/section/gi)){var n=parseInt(t.getAttribute("data-index-h"),10),r=parseInt(t.getAttribute("data-index-v"),10);V(n,r)}}}var e=".reveal .slides section",t=".reveal .slides>section",n=".reveal .slides>section.present>section",r={controls:!0,progress:!0,history:!1,keyboard:!0,overview:!0,center:!0,loop:!1,rtl:!1,autoSlide:0,mouseWheel:!1,rollingLinks:!0,theme:null,transition:"default",dependencies:[]},i=r.autoSlide,s=0,o=0,u,a,f=[],l={},c="WebkitPerspective"in document.body.style||"MozPerspective"in document.body.style||"msPerspective"in document.body.style||"OPerspective"in document.body.style||"perspective"in document.body.style,h="WebkitTransform"in document.body.style||"MozTransform"in document.body.style||"msTransform"in document.body.style||"OTransform"in document.body.style||"transform"in document.body.style,p=0,d=0,v=0,m=0,g={startX:0,startY:0,startSpan:0,startCount:0,handled:!1,threshold:80};return{initialize:y,slide:V,left:rt,right:it,up:st,down:ot,prev:ut,next:at,prevFragment:tt,nextFragment:et,navigateTo:V,navigateLeft:rt,navigateRight:it,navigateUp:st,navigateDown:ot,navigatePrev:ut,navigateNext:at,toggleOverview:I,addEventListeners:T,removeEventListeners:N,getIndices:Z,getPreviousSlide:function(){return u},getCurrentSlide:function(){return a},getQueryHash:function(){var e={};return location.search.replace(/[A-Z0-9]+?=(\w*)/gi,function(t){e[t.split("=").shift()]=t.split("=").pop()}),e},addEventListener:function(e,t,n){"addEventListener"in window&&(l.wrapper||document.querySelector(".reveal")).addEventListener(e,t,n)},removeEventListener:function(e,t,n){"addEventListener"in window&&(l.wrapper||document.querySelector(".reveal")).removeEventListener(e,t,n)}}}(); \ No newline at end of file +var Reveal=function(){"use strict";function y(e){if(!h&&!c){document.body.setAttribute("class","no-transforms");return}window.addEventListener("load",P,!1),C(r,e),w(),E()}function b(){l.theme=document.querySelector("#theme"),l.wrapper=document.querySelector(".reveal"),l.slides=document.querySelector(".reveal .slides");if(!l.wrapper.querySelector(".progress")&&r.progress){var e=document.createElement("div");e.classList.add("progress"),e.innerHTML="",l.wrapper.appendChild(e)}if(!l.wrapper.querySelector(".controls")&&r.controls){var t=document.createElement("aside");t.classList.add("controls"),t.innerHTML='',l.wrapper.appendChild(t)}if(!l.wrapper.querySelector(".state-background")){var n=document.createElement("div");n.classList.add("state-background"),l.wrapper.appendChild(n)}if(!l.wrapper.querySelector(".pause-overlay")){var i=document.createElement("div");i.classList.add("pause-overlay"),l.wrapper.appendChild(i)}l.progress=document.querySelector(".reveal .progress"),l.progressbar=document.querySelector(".reveal .progress span"),r.controls&&(l.controls=document.querySelector(".reveal .controls"),l.controlsLeft=k(document.querySelectorAll(".navigate-left")),l.controlsRight=k(document.querySelectorAll(".navigate-right")),l.controlsUp=k(document.querySelectorAll(".navigate-up")),l.controlsDown=k(document.querySelectorAll(".navigate-down")),l.controlsPrev=k(document.querySelectorAll(".navigate-prev")),l.controlsNext=k(document.querySelectorAll(".navigate-next")))}function w(){navigator.userAgent.match(/(iphone|ipod)/i)&&(document.documentElement.style.overflow="scroll",document.body.style.height="120%",window.addEventListener("load",M,!1),window.addEventListener("orientationchange",M,!1))}function E(){function o(){t.length&&head.js.apply(null,t),S()}var e=[],t=[];for(var n=0,i=r.dependencies.length;n'+i.innerHTML+"")}}}function P(){if(r.center){var t=k(document.querySelectorAll(e)),n=-l.wrapper.offsetHeight/2;for(var i=0,s=t.length;i3?"none":"block"}n[o].classList.remove("past"),n[o].classList.remove("present"),n[o].classList.remove("future"),ot&&n[o].classList.add("future"),u.querySelector("section")&&n[o].classList.add("stack")}n[t].classList.add("present");var l=n[t].getAttribute("data-state");l&&(f=f.concat(l.split(" ")));var c=n[t].getAttribute("data-autoslide");c?i=parseInt(c,10):i=r.autoSlide}else t=0;return t}function J(){if(r.progress&&l.progress){var n=k(document.querySelectorAll(t)),i=document.querySelectorAll(e+":not(.stack)").length,s=0;e:for(var o=0;o0,right:s0,down:o0||o>0)t+=s;o>0&&(t+="/"+o)}window.location.hash=t}}}function Z(e){var n=s,r=o;if(e){var i=!!e.parentNode.nodeName.match(/section/gi),u=i?e.parentNode:e,a=k(document.querySelectorAll(t));n=Math.max(a.indexOf(u),0),i&&(r=Math.max(k(e.parentNode.querySelectorAll("section")).indexOf(e),0))}return{h:n,v:r}}function et(){if(document.querySelector(n+".present")){var e=document.querySelectorAll(n+".present .fragment:not(.visible)");if(e.length)return e[0].classList.add("visible"),_("fragmentshown",{fragment:e[0]}),!0}else{var r=document.querySelectorAll(t+".present .fragment:not(.visible)");if(r.length)return r[0].classList.add("visible"),_("fragmentshown",{fragment:r[0]}),!0}return!1}function tt(){if(document.querySelector(n+".present")){var e=document.querySelectorAll(n+".present .fragment.visible");if(e.length)return e[e.length-1].classList.remove("visible"),_("fragmenthidden",{fragment:e[e.length-1]}),!0}else{var r=document.querySelectorAll(t+".present .fragment.visible");if(r.length)return r[r.length-1].classList.remove("visible"),_("fragmenthidden",{fragment:r[r.length-1]}),!0}return!1}function nt(){clearTimeout(d),i&&(d=setTimeout(at,i))}function rt(){(Q().left&&q()||tt()===!1)&&V(s-1)}function it(){(Q().right&&q()||et()===!1)&&V(s+1)}function st(){(Q().up&&q()||tt()===!1)&&V(s,o-1)}function ot(){(Q().down&&q()||et()===!1)&&V(s,o+1)}function ut(){if(tt()===!1)if(Q().up)st();else{var e=document.querySelector(t+".past:nth-child("+s+")");e&&(o=e.querySelectorAll("section").length+1||undefined,s--,V())}}function at(){et()===!1&&(Q().down?ot():it()),nt()}function ft(e){var t=document.activeElement,n=!(!document.activeElement||!document.activeElement.type&&!document.activeElement.href&&document.activeElement.contentEditable==="inherit");if(n||e.shiftKey||e.altKey||e.ctrlKey||e.metaKey)return;var r=!0;switch(e.keyCode){case 80:case 33:ut();break;case 78:case 34:at();break;case 72:case 37:rt();break;case 76:case 39:it();break;case 75:case 38:st();break;case 74:case 40:ot();break;case 36:V(0);break;case 35:V(Number.MAX_VALUE);break;case 32:q()?F():at();break;case 13:q()?F():r=!1;break;case 66:case 190:W();break;case 70:R();break;default:r=!1}r?e.preventDefault():e.keyCode===27&&c&&(I(),e.preventDefault()),nt()}function lt(e){g.startX=e.touches[0].clientX,g.startY=e.touches[0].clientY,g.startCount=e.touches.length,e.touches.length===2&&r.overview&&(g.startSpan=A({x:e.touches[1].clientX,y:e.touches[1].clientY},{x:g.startX,y:g.startY}))}function ct(e){if(!g.handled){var t=e.touches[0].clientX,n=e.touches[0].clientY;if(e.touches.length===2&&g.startCount===2&&r.overview){var i=A({x:e.touches[1].clientX,y:e.touches[1].clientY},{x:g.startX,y:g.startY});Math.abs(g.startSpan-i)>g.threshold&&(g.handled=!0,ig.threshold&&Math.abs(s)>Math.abs(o)?(g.handled=!0,rt()):s<-g.threshold&&Math.abs(s)>Math.abs(o)?(g.handled=!0,it()):o>g.threshold?(g.handled=!0,st()):o<-g.threshold&&(g.handled=!0,ot()),e.preventDefault()}}else navigator.userAgent.match(/android/gi)&&e.preventDefault()}function ht(e){g.handled=!1}function pt(e){clearTimeout(p),p=setTimeout(function(){var t=e.detail||-e.wheelDelta;t>0?at():ut()},100)}function dt(e){var n=k(document.querySelectorAll(t)).length,r=Math.floor(e.clientX/l.wrapper.offsetWidth*n);V(r)}function vt(e){G()}function mt(e){P()}function gt(e){if(q()){e.preventDefault(),F();var t=e.target;while(t&&!t.nodeName.match(/section/gi))t=t.parentNode;if(t.nodeName.match(/section/gi)){var n=parseInt(t.getAttribute("data-index-h"),10),r=parseInt(t.getAttribute("data-index-v"),10);V(n,r)}}}var e=".reveal .slides section",t=".reveal .slides>section",n=".reveal .slides>section.present>section",r={controls:!0,progress:!0,history:!1,keyboard:!0,overview:!0,center:!0,loop:!1,rtl:!1,autoSlide:0,mouseWheel:!1,rollingLinks:!0,theme:null,transition:"default",dependencies:[]},i=r.autoSlide,s=0,o=0,u,a,f=[],l={},c="WebkitPerspective"in document.body.style||"MozPerspective"in document.body.style||"msPerspective"in document.body.style||"OPerspective"in document.body.style||"perspective"in document.body.style,h="WebkitTransform"in document.body.style||"MozTransform"in document.body.style||"msTransform"in document.body.style||"OTransform"in document.body.style||"transform"in document.body.style,p=0,d=0,v=0,m=0,g={startX:0,startY:0,startSpan:0,startCount:0,handled:!1,threshold:80};return{initialize:y,slide:V,left:rt,right:it,up:st,down:ot,prev:ut,next:at,prevFragment:tt,nextFragment:et,navigateTo:V,navigateLeft:rt,navigateRight:it,navigateUp:st,navigateDown:ot,navigatePrev:ut,navigateNext:at,toggleOverview:I,addEventListeners:T,removeEventListeners:N,getIndices:Z,getPreviousSlide:function(){return u},getCurrentSlide:function(){return a},getQueryHash:function(){var e={};return location.search.replace(/[A-Z0-9]+?=(\w*)/gi,function(t){e[t.split("=").shift()]=t.split("=").pop()}),e},addEventListener:function(e,t,n){"addEventListener"in window&&(l.wrapper||document.querySelector(".reveal")).addEventListener(e,t,n)},removeEventListener:function(e,t,n){"addEventListener"in window&&(l.wrapper||document.querySelector(".reveal")).removeEventListener(e,t,n)}}}(); \ No newline at end of file