prevent overview click events after calling Reveal.removeEventListeners

This commit is contained in:
Hakim El Hattab committed 2013-02-24 00:52:54 -05:00
1 parent f795cb0269
commit 40759435e4
2 files changed
+10 -3

No files matched your search

+8 -1
View File
@@ -129,6 +129,9 @@ var Reveal = (function(){
// A delay used to deactivate the overview mode
deactivateOverviewTimeout = 0,
// Flags if the interaction event listeners are bound
eventsAreBound = false,
// Holds information about the currently ongoing touch input
touch = {
startX: 0,
@@ -390,6 +393,8 @@ var Reveal = (function(){
*/
function addEventListeners() {
eventsAreBound = true;
window.addEventListener( 'hashchange', onWindowHashChange, false );
window.addEventListener( 'resize', onWindowResize, false );
@@ -424,6 +429,8 @@ var Reveal = (function(){
*/
function removeEventListeners() {
eventsAreBound = false;
document.removeEventListener( 'keydown', onDocumentKeyDown, false );
window.removeEventListener( 'hashchange', onWindowHashChange, false );
window.removeEventListener( 'resize', onWindowResize, false );
@@ -1801,7 +1808,7 @@ var Reveal = (function(){
// TODO There's a bug here where the event listeners are not
// removed after deactivating the overview.
if( isOverview() ) {
if( eventsAreBound && isOverview() ) {
event.preventDefault();
deactivateOverview();
+2 -2
View File
@@ -1,8 +1,8 @@
/*!
* reveal.js 2.3 (2013-02-24, 00:42)
* reveal.js 2.3 (2013-02-24, 00:51)
* http://lab.hakim.se/reveal-js
* MIT licensed
*
* Copyright (C) 2013 Hakim El Hattab, http://hakim.se
*/
var Reveal=function(){"use strict";function E(e){if(!d&&!p){document.body.setAttribute("class","no-transforms");return}window.addEventListener("load",B,!1),A(i,e),x(),T()}function S(){h.theme=document.querySelector("#theme"),h.wrapper=document.querySelector(".reveal"),h.slides=document.querySelector(".reveal .slides");if(!h.wrapper.querySelector(".progress")&&i.progress){var e=document.createElement("div");e.classList.add("progress"),e.innerHTML="<span></span>",h.wrapper.appendChild(e)}if(!h.wrapper.querySelector(".controls")&&i.controls){var t=document.createElement("aside");t.classList.add("controls"),t.innerHTML='<div class="navigate-left"></div><div class="navigate-right"></div><div class="navigate-up"></div><div class="navigate-down"></div>',h.wrapper.appendChild(t)}if(!h.wrapper.querySelector(".state-background")){var n=document.createElement("div");n.classList.add("state-background"),h.wrapper.appendChild(n)}if(!h.wrapper.querySelector(".pause-overlay")){var r=document.createElement("div");r.classList.add("pause-overlay"),h.wrapper.appendChild(r)}h.progress=document.querySelector(".reveal .progress"),h.progressbar=document.querySelector(".reveal .progress span"),i.controls&&(h.controls=document.querySelector(".reveal .controls"),h.controlsLeft=O(document.querySelectorAll(".navigate-left")),h.controlsRight=O(document.querySelectorAll(".navigate-right")),h.controlsUp=O(document.querySelectorAll(".navigate-up")),h.controlsDown=O(document.querySelectorAll(".navigate-down")),h.controlsPrev=O(document.querySelectorAll(".navigate-prev")),h.controlsNext=O(document.querySelectorAll(".navigate-next")))}function x(){/iphone|ipod|android/gi.test(navigator.userAgent)&&!/crios/gi.test(navigator.userAgent)&&(window.addEventListener("load",_,!1),window.addEventListener("orientationchange",_,!1))}function T(){function o(){t.length&&head.js.apply(null,t),N()}var e=[],t=[];for(var n=0,r=i.dependencies.length;n<r;n++){var s=i.dependencies[n];if(!s.condition||s.condition())s.async?t.push(s.src):e.push(s.src),typeof s.callback=="function"&&head.ready(s.src.match(/([\w\d_\-]*)\.?js$|[^\\\/]*$/i)[0],s.callback)}e.length?(head.ready(o),head.js.apply(null,e)):o()}function N(){S(),k(),C(),B(),Z(),it(),setTimeout(function(){D("ready",{indexh:o,indexv:u,currentSlide:f})},1)}function C(e){h.wrapper.classList.remove(i.transition),typeof e=="object"&&A(i,e),p===!1&&(i.transition="linear"),h.wrapper.classList.add(i.transition),h.controls.style.display=i.controls&&h.controls?"block":"none",h.progress.style.display=i.progress&&h.progress?"block":"none",h.wrapper.classList.toggle("rtl",i.rtl),h.wrapper.classList.toggle("center",i.center),i.mouseWheel?(document.addEventListener("DOMMouseScroll",mt,!1),document.addEventListener("mousewheel",mt,!1)):(document.removeEventListener("DOMMouseScroll",mt,!1),document.removeEventListener("mousewheel",mt,!1)),i.rollingLinks?P():H();if(i.theme&&h.theme){var t=h.theme.getAttribute("href"),n=/[^\/]*?(?=\.css)/,r=t.match(n)[0];i.theme!==r&&(t=t.replace(n,i.theme),h.theme.setAttribute("href",t))}}function k(){window.addEventListener("hashchange",Tt,!1),window.addEventListener("resize",Nt,!1),i.touch&&(document.addEventListener("touchstart",pt,!1),document.addEventListener("touchmove",dt,!1),document.addEventListener("touchend",vt,!1)),i.keyboard&&document.addEventListener("keydown",ht,!1),i.progress&&h.progress&&h.progress.addEventListener("click",gt,!1);if(i.controls&&h.controls){var e="ontouchstart"in window&&window.ontouchstart!=null?"touchstart":"click";h.controlsLeft.forEach(function(t){t.addEventListener(e,yt,!1)}),h.controlsRight.forEach(function(t){t.addEventListener(e,bt,!1)}),h.controlsUp.forEach(function(t){t.addEventListener(e,wt,!1)}),h.controlsDown.forEach(function(t){t.addEventListener(e,Et,!1)}),h.controlsPrev.forEach(function(t){t.addEventListener(e,St,!1)}),h.controlsNext.forEach(function(t){t.addEventListener(e,xt,!1)})}}function L(){document.removeEventListener("keydown",ht,!1),window.removeEventListener("hashchange",Tt,!1),window.removeEventListener("resize",Nt,!1),i.touch&&(document.removeEventListener("touchstart",pt,!1),document.removeEventListener("touchmove",dt,!1),document.removeEventListener("touchend",vt,!1)),i.progress&&h.progress&&h.progress.removeEventListener("click",gt,!1);if(i.controls&&h.controls){var e="ontouchstart"in window&&window.ontouchstart!=null?"touchstart":"click";h.controlsLeft.forEach(function(t){t.removeEventListener(e,yt,!1)}),h.controlsRight.forEach(function(t){t.removeEventListener(e,bt,!1)}),h.controlsUp.forEach(function(t){t.removeEventListener(e,wt,!1)}),h.controlsDown.forEach(function(t){t.removeEventListener(e,Et,!1)}),h.controlsPrev.forEach(function(t){t.removeEventListener(e,St,!1)}),h.controlsNext.forEach(function(t){t.removeEventListener(e,xt,!1)})}}function A(e,t){for(var n in t)e[n]=t[n]}function O(e){return Array.prototype.slice.call(e)}function M(e,t){var n=e.x-t.x,r=e.y-t.y;return Math.sqrt(n*n+r*r)}function _(){window.orientation===0?Line truncated
var Reveal=function(){"use strict";function S(e){if(!d&&!p){document.body.setAttribute("class","no-transforms");return}window.addEventListener("load",j,!1),O(i,e),T(),N()}function x(){h.theme=document.querySelector("#theme"),h.wrapper=document.querySelector(".reveal"),h.slides=document.querySelector(".reveal .slides");if(!h.wrapper.querySelector(".progress")&&i.progress){var e=document.createElement("div");e.classList.add("progress"),e.innerHTML="<span></span>",h.wrapper.appendChild(e)}if(!h.wrapper.querySelector(".controls")&&i.controls){var t=document.createElement("aside");t.classList.add("controls"),t.innerHTML='<div class="navigate-left"></div><div class="navigate-right"></div><div class="navigate-up"></div><div class="navigate-down"></div>',h.wrapper.appendChild(t)}if(!h.wrapper.querySelector(".state-background")){var n=document.createElement("div");n.classList.add("state-background"),h.wrapper.appendChild(n)}if(!h.wrapper.querySelector(".pause-overlay")){var r=document.createElement("div");r.classList.add("pause-overlay"),h.wrapper.appendChild(r)}h.progress=document.querySelector(".reveal .progress"),h.progressbar=document.querySelector(".reveal .progress span"),i.controls&&(h.controls=document.querySelector(".reveal .controls"),h.controlsLeft=M(document.querySelectorAll(".navigate-left")),h.controlsRight=M(document.querySelectorAll(".navigate-right")),h.controlsUp=M(document.querySelectorAll(".navigate-up")),h.controlsDown=M(document.querySelectorAll(".navigate-down")),h.controlsPrev=M(document.querySelectorAll(".navigate-prev")),h.controlsNext=M(document.querySelectorAll(".navigate-next")))}function T(){/iphone|ipod|android/gi.test(navigator.userAgent)&&!/crios/gi.test(navigator.userAgent)&&(window.addEventListener("load",D,!1),window.addEventListener("orientationchange",D,!1))}function N(){function o(){t.length&&head.js.apply(null,t),C()}var e=[],t=[];for(var n=0,r=i.dependencies.length;n<r;n++){var s=i.dependencies[n];if(!s.condition||s.condition())s.async?t.push(s.src):e.push(s.src),typeof s.callback=="function"&&head.ready(s.src.match(/([\w\d_\-]*)\.?js$|[^\\\/]*$/i)[0],s.callback)}e.length?(head.ready(o),head.js.apply(null,e)):o()}function C(){x(),L(),k(),j(),et(),st(),setTimeout(function(){P("ready",{indexh:o,indexv:u,currentSlide:f})},1)}function k(e){h.wrapper.classList.remove(i.transition),typeof e=="object"&&O(i,e),p===!1&&(i.transition="linear"),h.wrapper.classList.add(i.transition),h.controls.style.display=i.controls&&h.controls?"block":"none",h.progress.style.display=i.progress&&h.progress?"block":"none",h.wrapper.classList.toggle("rtl",i.rtl),h.wrapper.classList.toggle("center",i.center),i.mouseWheel?(document.addEventListener("DOMMouseScroll",gt,!1),document.addEventListener("mousewheel",gt,!1)):(document.removeEventListener("DOMMouseScroll",gt,!1),document.removeEventListener("mousewheel",gt,!1)),i.rollingLinks?H():B();if(i.theme&&h.theme){var t=h.theme.getAttribute("href"),n=/[^\/]*?(?=\.css)/,r=t.match(n)[0];i.theme!==r&&(t=t.replace(n,i.theme),h.theme.setAttribute("href",t))}}function L(){w=!0,window.addEventListener("hashchange",Nt,!1),window.addEventListener("resize",Ct,!1),i.touch&&(document.addEventListener("touchstart",dt,!1),document.addEventListener("touchmove",vt,!1),document.addEventListener("touchend",mt,!1)),i.keyboard&&document.addEventListener("keydown",pt,!1),i.progress&&h.progress&&h.progress.addEventListener("click",yt,!1);if(i.controls&&h.controls){var e="ontouchstart"in window&&window.ontouchstart!=null?"touchstart":"click";h.controlsLeft.forEach(function(t){t.addEventListener(e,bt,!1)}),h.controlsRight.forEach(function(t){t.addEventListener(e,wt,!1)}),h.controlsUp.forEach(function(t){t.addEventListener(e,Et,!1)}),h.controlsDown.forEach(function(t){t.addEventListener(e,St,!1)}),h.controlsPrev.forEach(function(t){t.addEventListener(e,xt,!1)}),h.controlsNext.forEach(function(t){t.addEventListener(e,Tt,!1)})}}function A(){w=!1,document.removeEventListener("keydown",pt,!1),window.removeEventListener("hashchange",Nt,!1),window.removeEventListener("resize",Ct,!1),i.touch&&(document.removeEventListener("touchstart",dt,!1),document.removeEventListener("touchmove",vt,!1),document.removeEventListener("touchend",mt,!1)),i.progress&&h.progress&&h.progress.removeEventListener("click",yt,!1);if(i.controls&&h.controls){var e="ontouchstart"in window&&window.ontouchstart!=null?"touchstart":"click";h.controlsLeft.forEach(function(t){t.removeEventListener(e,bt,!1)}),h.controlsRight.forEach(function(t){t.removeEventListener(e,wt,!1)}),h.controlsUp.forEach(function(t){t.removeEventListener(e,Et,!1)}),h.controlsDown.forEach(function(t){t.removeEventListener(e,St,!1)}),h.controlsPrev.forEach(function(t){t.removeEventListener(e,xt,!1)}),h.controlsNext.forEach(function(t){t.removeEventListener(e,Tt,!1)})}}function O(e,t){for(var n in t)e[n]=t[n]}function M(e){return Array.prototype.slice.call(e)}function _(e,t){var n=e.x-t.x,r=e.y-t.y;return Math.sqrt(n*n+r*r)}function D(){window.orienLine truncated