add autoSlideStoppable config value, allows autoSlide to be aborted on user input

This commit is contained in:
Hakim El Hattab committed 2013-10-11 08:40:40 -04:00
1 parent 1421934fde
commit e94f62a58f
3 files changed
+34 -10

No files matched your search

+3
View File
@@ -97,6 +97,9 @@ Reveal.initialize({
// by using a data-autoslide attribute on your slides // by using a data-autoslide attribute on your slides
autoSlide: 0, autoSlide: 0,
// Stop auto-sliding after user input
autoSlideStoppable: true,
// Enable slide navigation via mouse wheel // Enable slide navigation via mouse wheel
mouseWheel: false, mouseWheel: false,
+29 -8
View File
@@ -68,6 +68,9 @@ var Reveal = (function(){
// by using a data-autoslide attribute on your slides // by using a data-autoslide attribute on your slides
autoSlide: 0, autoSlide: 0,
// Stop auto-sliding after user input
autoSlideStoppable: false,
// Enable slide navigation via mouse wheel // Enable slide navigation via mouse wheel
mouseWheel: false, mouseWheel: false,
@@ -2349,11 +2352,21 @@ var Reveal = (function(){
// ----------------------------- EVENTS -------------------------------// // ----------------------------- EVENTS -------------------------------//
// --------------------------------------------------------------------// // --------------------------------------------------------------------//
/**
* Called by all event handlers that are based on user
* input.
*/
function onUserInput( event ) {
if( config.autoSlideStoppable ) {
config.autoSlide = 0;
cancelAutoSlide();
}
}
/** /**
* Handler for the document level 'keydown' event. * Handler for the document level 'keydown' event.
*
* @param {Object} event
*/ */
function onDocumentKeyDown( event ) { function onDocumentKeyDown( event ) {
@@ -2453,6 +2466,8 @@ var Reveal = (function(){
// another timeout // another timeout
cueAutoSlide(); cueAutoSlide();
onUserInput( event );
} }
/** /**
@@ -2477,6 +2492,8 @@ var Reveal = (function(){
} ); } );
} }
onUserInput( event );
} }
/** /**
@@ -2583,6 +2600,8 @@ var Reveal = (function(){
onTouchStart( event ); onTouchStart( event );
} }
onUserInput( event );
} }
/** /**
@@ -2646,17 +2665,19 @@ var Reveal = (function(){
slide( slideIndex ); slide( slideIndex );
onUserInput( event );
} }
/** /**
* Event handler for navigation control buttons. * Event handler for navigation control buttons.
*/ */
function onNavigateLeftClicked( event ) { event.preventDefault(); navigateLeft(); } function onNavigateLeftClicked( event ) { event.preventDefault(); navigateLeft(); onUserInput(); }
function onNavigateRightClicked( event ) { event.preventDefault(); navigateRight(); } function onNavigateRightClicked( event ) { event.preventDefault(); navigateRight(); onUserInput(); }
function onNavigateUpClicked( event ) { event.preventDefault(); navigateUp(); } function onNavigateUpClicked( event ) { event.preventDefault(); navigateUp(); onUserInput(); }
function onNavigateDownClicked( event ) { event.preventDefault(); navigateDown(); } function onNavigateDownClicked( event ) { event.preventDefault(); navigateDown(); onUserInput(); }
function onNavigatePrevClicked( event ) { event.preventDefault(); navigatePrev(); } function onNavigatePrevClicked( event ) { event.preventDefault(); navigatePrev(); onUserInput(); }
function onNavigateNextClicked( event ) { event.preventDefault(); navigateNext(); } function onNavigateNextClicked( event ) { event.preventDefault(); navigateNext(); onUserInput(); }
/** /**
* Handler for the window level 'hashchange' event. * Handler for the window level 'hashchange' event.
+2 -2
View File
@@ -1,8 +1,8 @@
/*! /*!
* reveal.js 2.6.0-dev (2013-10-10, 09:19) * reveal.js 2.6.0-dev (2013-10-11, 08:40)
* http://lab.hakim.se/reveal-js * http://lab.hakim.se/reveal-js
* MIT licensed * MIT licensed
* *
* Copyright (C) 2013 Hakim El Hattab, http://hakim.se * Copyright (C) 2013 Hakim El Hattab, http://hakim.se
*/ */
var Reveal=function(){"use strict";function a(a){return b(),Mb||Lb?(window.addEventListener("load",C,!1),l(Sb,a),s(),c(),void 0):(document.body.setAttribute("class","no-transforms"),void 0)}function b(){Lb="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,Mb="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,Nb=navigator.userAgent.match(/(iphone|ipod|android)/gi)}function c(){function a(){c.length&&head.js.apply(null,c),d()}for(var b=[],c=[],e=0,f=Sb.dependencies.length;f>e;e++){var g=Sb.dependencies[e];(!g.condition||g.condition())&&(g.async?c.push(g.src):b.push(g.src),"function"==typeof g.callback&&head.ready(g.src.match(/([\w\d_\-]*)\.?js$|[^\\\/]*$/i)[0],g.callback))}b.length?(head.ready(a),head.js.apply(null,b)):a()}function d(){f(),e(),i(),ab(),setTimeout(function(){Xb.slides.classList.remove("no-transition"),Tb=!0,u("ready",{indexh:Hb,indexv:Ib,currentSlide:Kb})},1)}function e(){var a=m(document.querySelectorAll(Pb));a.forEach(function(a){var b=m(a.querySelectorAll("section"));b.forEach(function(a,b){b>0&&a.classList.add("future")})})}function f(){Xb.theme=document.querySelector("#theme"),Xb.wrapper=document.querySelector(".reveal"),Xb.slides=document.querySelector(".reveal .slides"),Xb.slides.classList.add("no-transition"),Xb.background=g(Xb.wrapper,"div","backgrounds",null),Xb.progress=g(Xb.wrapper,"div","progress","<span></span>"),Xb.progressbar=Xb.progress.querySelector("span"),g(Xb.wrapper,"aside","controls",'<div class="navigate-left"></div><div class="navigate-right"></div><div class="navigate-up"></div><div class="navigate-down"></div>'),g(Xb.wrapper,"div","state-background",null),g(Xb.wrapper,"div","pause-overlay",null),Xb.controls=document.querySelector(".reveal .controls"),Xb.controlsLeft=m(document.querySelectorAll(".navigate-left")),Xb.controlsRight=m(document.querySelectorAll(".navigate-right")),Xb.controlsUp=m(document.querySelectorAll(".navigate-up")),Xb.controlsDown=m(document.querySelectorAll(".navigate-down")),Xb.controlsPrev=m(document.querySelectorAll(".navigate-prev")),Xb.controlsNext=m(document.querySelectorAll(".navigate-next"))}function g(a,b,c,d){var e=a.querySelector("."+c);return e||(e=document.createElement(b),e.classList.add(c),null!==d&&(e.innerHTML=d),a.appendChild(e)),e}function h(){function a(a,b){var c={background:a.getAttribute("data-background"),backgroundSize:a.getAttribute("data-background-size"),backgroundImage:a.getAttribute("data-background-image"),backgroundColor:a.getAttribute("data-background-color"),backgroundRepeat:a.getAttribute("data-background-repeat"),backgroundPosition:a.getAttribute("data-background-position"),backgroundTransition:a.getAttribute("data-background-transition")},d=document.createElement("div");return d.className="slide-background",c.background&&(/^(http|file|\/\/)/gi.test(c.background)||/\.(png|jpg|jpeg|gif|bmp)$/gi.test(c.background)?d.style.backgroundImage="url("+c.background+")":d.style.background=c.background),c.backgroundSize&&(d.style.backgroundSize=c.backgroundSize),c.backgroundImage&&(d.style.backgroundImage='url("'+c.backgroundImage+'")'),c.backgroundColor&&(d.style.backgroundColor=c.backgroundColor),c.backgroundRepeat&&(d.style.backgroundRepeat=c.backgroundRepeat),c.backgroundPosition&&(d.style.backgroundPosition=c.backgroundPosition),c.backgroundTransition&&d.setAttribute("data-background-transition",c.backgroundTransition),b.appendChild(d),d}r()&&document.body.classList.add("print-pdf"),Xb.background.innerHTML="",Xb.background.classList.add("no-transition"),m(document.querySelectorAll(Pb)).forEach(function(b){var c;c=r()?a(b,b):a(b,Xb.background),m(b.querySelectorAll("section")).forEach(function(b){r()?a(b,b):a(b,c)})}),Sb.parallaxBackgroundImage?(Xb.background.style.backgroundImage='url("'+Sb.parallaxBackgroundImage+'")',Xb.background.style.backgroundSize=Sb.parallaxBackgroundSize,setTimeout(function(){Xb.wrapper.classList.add("has-parallax-background")},1)):(Xb.background.style.backgroundImage="",Xb.wrapper.classList.remove("has-parallax-background"))}function i(a){if(Xb.wrapper.classList.remove(Sb.transition),"object"==typeof a&&l(Sb,a),Lb===!1&&(Sb.transition="linear"),Xb.wrapper.classList.add(Sb.transition),Xb.wrapper.setAttribute("data-transition-speed",Sb.transitionSpeed),Xb.wrapper.setAttribute("data-background-transition",Sb.backgroundTransition),Xb.controls.style.display=Sb.controls?"block":"none",Xb.progress.style.display=Sb.progress?"block":"none",Sb.rtl?Xb.wrapper.classList.add("rtl"):Xb.wrapper.classList.remove("rtl"),Sb.center?Xb.wrapper.classList.add("center"):Xb.wrapper.classList.remove("center"),Sb.mouseWheel?(document.addEventListener("DOMMouseScroll",ub,!1),document.addEventListener("mousewheel",ub,!1)):(document.removeEventLiLine truncated var Reveal=function(){"use strict";function a(a){return b(),Nb||Mb?(window.addEventListener("load",C,!1),l(Tb,a),s(),c(),void 0):(document.body.setAttribute("class","no-transforms"),void 0)}function b(){Mb="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,Nb="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,Ob=navigator.userAgent.match(/(iphone|ipod|android)/gi)}function c(){function a(){c.length&&head.js.apply(null,c),d()}for(var b=[],c=[],e=0,f=Tb.dependencies.length;f>e;e++){var g=Tb.dependencies[e];(!g.condition||g.condition())&&(g.async?c.push(g.src):b.push(g.src),"function"==typeof g.callback&&head.ready(g.src.match(/([\w\d_\-]*)\.?js$|[^\\\/]*$/i)[0],g.callback))}b.length?(head.ready(a),head.js.apply(null,b)):a()}function d(){f(),e(),i(),ab(),setTimeout(function(){Yb.slides.classList.remove("no-transition"),Ub=!0,u("ready",{indexh:Ib,indexv:Jb,currentSlide:Lb})},1)}function e(){var a=m(document.querySelectorAll(Qb));a.forEach(function(a){var b=m(a.querySelectorAll("section"));b.forEach(function(a,b){b>0&&a.classList.add("future")})})}function f(){Yb.theme=document.querySelector("#theme"),Yb.wrapper=document.querySelector(".reveal"),Yb.slides=document.querySelector(".reveal .slides"),Yb.slides.classList.add("no-transition"),Yb.background=g(Yb.wrapper,"div","backgrounds",null),Yb.progress=g(Yb.wrapper,"div","progress","<span></span>"),Yb.progressbar=Yb.progress.querySelector("span"),g(Yb.wrapper,"aside","controls",'<div class="navigate-left"></div><div class="navigate-right"></div><div class="navigate-up"></div><div class="navigate-down"></div>'),g(Yb.wrapper,"div","state-background",null),g(Yb.wrapper,"div","pause-overlay",null),Yb.controls=document.querySelector(".reveal .controls"),Yb.controlsLeft=m(document.querySelectorAll(".navigate-left")),Yb.controlsRight=m(document.querySelectorAll(".navigate-right")),Yb.controlsUp=m(document.querySelectorAll(".navigate-up")),Yb.controlsDown=m(document.querySelectorAll(".navigate-down")),Yb.controlsPrev=m(document.querySelectorAll(".navigate-prev")),Yb.controlsNext=m(document.querySelectorAll(".navigate-next"))}function g(a,b,c,d){var e=a.querySelector("."+c);return e||(e=document.createElement(b),e.classList.add(c),null!==d&&(e.innerHTML=d),a.appendChild(e)),e}function h(){function a(a,b){var c={background:a.getAttribute("data-background"),backgroundSize:a.getAttribute("data-background-size"),backgroundImage:a.getAttribute("data-background-image"),backgroundColor:a.getAttribute("data-background-color"),backgroundRepeat:a.getAttribute("data-background-repeat"),backgroundPosition:a.getAttribute("data-background-position"),backgroundTransition:a.getAttribute("data-background-transition")},d=document.createElement("div");return d.className="slide-background",c.background&&(/^(http|file|\/\/)/gi.test(c.background)||/\.(png|jpg|jpeg|gif|bmp)$/gi.test(c.background)?d.style.backgroundImage="url("+c.background+")":d.style.background=c.background),c.backgroundSize&&(d.style.backgroundSize=c.backgroundSize),c.backgroundImage&&(d.style.backgroundImage='url("'+c.backgroundImage+'")'),c.backgroundColor&&(d.style.backgroundColor=c.backgroundColor),c.backgroundRepeat&&(d.style.backgroundRepeat=c.backgroundRepeat),c.backgroundPosition&&(d.style.backgroundPosition=c.backgroundPosition),c.backgroundTransition&&d.setAttribute("data-background-transition",c.backgroundTransition),b.appendChild(d),d}r()&&document.body.classList.add("print-pdf"),Yb.background.innerHTML="",Yb.background.classList.add("no-transition"),m(document.querySelectorAll(Qb)).forEach(function(b){var c;c=r()?a(b,b):a(b,Yb.background),m(b.querySelectorAll("section")).forEach(function(b){r()?a(b,b):a(b,c)})}),Tb.parallaxBackgroundImage?(Yb.background.style.backgroundImage='url("'+Tb.parallaxBackgroundImage+'")',Yb.background.style.backgroundSize=Tb.parallaxBackgroundSize,setTimeout(function(){Yb.wrapper.classList.add("has-parallax-background")},1)):(Yb.background.style.backgroundImage="",Yb.wrapper.classList.remove("has-parallax-background"))}function i(a){if(Yb.wrapper.classList.remove(Tb.transition),"object"==typeof a&&l(Tb,a),Mb===!1&&(Tb.transition="linear"),Yb.wrapper.classList.add(Tb.transition),Yb.wrapper.setAttribute("data-transition-speed",Tb.transitionSpeed),Yb.wrapper.setAttribute("data-background-transition",Tb.backgroundTransition),Yb.controls.style.display=Tb.controls?"block":"none",Yb.progress.style.display=Tb.progress?"block":"none",Tb.rtl?Yb.wrapper.classList.add("rtl"):Yb.wrapper.classList.remove("rtl"),Tb.center?Yb.wrapper.classList.add("center"):Yb.wrapper.classList.remove("center"),Tb.mouseWheel?(document.addEventListener("DOMMouseScroll",vb,!1),document.addEventListener("mousewheel",vb,!1)):(document.removeEventLiLine truncated