fix issue with click event target on overview slides

This commit is contained in:
Hakim El Hattab committed 2012-11-25 09:45:16 -05:00
1 parent e34ed3c2ff
commit 385bfd3717
2 files changed
+27 -10

No files matched your search

+25 -8
View File
@@ -102,6 +102,9 @@ var Reveal = (function(){
// Delays updates to the URL due to a Chrome thumbnailer bug
writeURLTimeout = 0,
// A delay used to ativate the overview mode
activateOverviewTimeout = 0,
// Holds information about the currently ongoing touch input
touch = {
startX: 0,
@@ -575,10 +578,12 @@ var Reveal = (function(){
dom.wrapper.classList.add( 'overview' );
clearTimeout( activateOverviewTimeout );
// Not the pretties solution, but need to let the overview
// class apply first so that slides are measured accurately
// before we can positon them
setTimeout( function(){
activateOverviewTimeout = setTimeout( function(){
var horizontalSlides = document.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR );
@@ -616,7 +621,7 @@ var Reveal = (function(){
// Navigate to this slide on click
vslide.addEventListener( 'click', onOverviewSlideClicked, true );
}
}
else {
@@ -643,6 +648,8 @@ var Reveal = (function(){
// Only proceed if enabled in config
if( config.overview ) {
clearTimeout( activateOverviewTimeout );
dom.wrapper.classList.remove( 'overview' );
// Select all slides
@@ -651,6 +658,8 @@ var Reveal = (function(){
for( var i = 0, len = slides.length; i < len; i++ ) {
var element = slides[i];
element.style.display = '';
// Resets all transforms to use the external styles
element.style.WebkitTransform = '';
element.style.MozTransform = '';
@@ -658,7 +667,7 @@ var Reveal = (function(){
element.style.OTransform = '';
element.style.transform = '';
element.removeEventListener( 'click', onOverviewSlideClicked );
element.removeEventListener( 'click', onOverviewSlideClicked, true );
}
slide( indexh, indexv );
@@ -762,7 +771,7 @@ var Reveal = (function(){
// Query all horizontal slides in the deck
var horizontalSlides = document.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR );
// If no vertical index is specified and the upcoming slide is a
// stack, resume at its previous vertical index
if( v === undefined ) {
@@ -829,7 +838,7 @@ var Reveal = (function(){
// Store references to the previous and current slides
currentSlide = currentVerticalSlides[ indexv ] || currentHorizontalSlide;
// Show fragment, if specified
if( ( indexh !== indexhBefore || indexv !== indexvBefore ) && f ) {
var fragments = currentSlide.querySelectorAll( '.fragment' );
@@ -1534,10 +1543,18 @@ var Reveal = (function(){
deactivateOverview();
var h = parseInt( event.target.getAttribute( 'data-index-h' ), 10 ),
v = parseInt( event.target.getAttribute( 'data-index-v' ), 10 );
var element = event.target;
slide( h, v );
while( element && !element.nodeName.match( /section/gi ) ) {
element = element.parentNode;
}
if( element.nodeName.match( /section/gi ) ) {
var h = parseInt( element.getAttribute( 'data-index-h' ), 10 ),
v = parseInt( element.getAttribute( 'data-index-v' ), 10 );
slide( h, v );
}
}
}
+2 -2
View File
@@ -1,8 +1,8 @@
/*!
* reveal.js 2.2 (2012-11-23, 15:47)
* reveal.js 2.2 (2012-11-25, 09:42)
* http://lab.hakim.se/reveal-js
* MIT licensed
*
* Copyright (C) 2011-2012 Hakim El Hattab, http://hakim.se
*/
var Reveal=function(){"use strict";function g(e){if(!h&&!c){document.body.setAttribute("class","no-transforms");return}window.addEventListener("load",D,!1),N(r,e),b(),w()}function y(){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="<span></span>",l.wrapper.appendChild(e)}if(!l.wrapper.querySelector(".controls")&&r.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>',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=C(document.querySelectorAll(".navigate-left")),l.controlsRight=C(document.querySelectorAll(".navigate-right")),l.controlsUp=C(document.querySelectorAll(".navigate-up")),l.controlsDown=C(document.querySelectorAll(".navigate-down")),l.controlsPrev=C(document.querySelectorAll(".navigate-prev")),l.controlsNext=C(document.querySelectorAll(".navigate-next")))}function b(){navigator.userAgent.match(/(iphone|ipod)/i)&&(document.documentElement.style.overflow="scroll",document.body.style.height="120%",window.addEventListener("load",O,!1),window.addEventListener("orientationchange",O,!1))}function w(){function o(){t.length&&head.js.apply(null,t),E()}var e=[],t=[];for(var n=0,i=r.dependencies.length;n<i;n++){var s=r.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 E(){y(),x(),S(),D(),Q(),tt(),setTimeout(function(){M("ready",{indexh:s,indexv:o,currentSlide:a})},1)}function S(){c===!1&&(r.transition="linear"),r.controls&&l.controls&&(l.controls.style.display="block"),r.progress&&l.progress&&(l.progress.style.display="block"),r.transition!=="default"&&l.wrapper.classList.add(r.transition),r.rtl&&l.wrapper.classList.add("rtl"),r.center&&l.wrapper.classList.add("center"),r.mouseWheel&&(document.addEventListener("DOMMouseScroll",ht,!1),document.addEventListener("mousewheel",ht,!1)),r.rollingLinks&&_();if(r.theme&&l.theme){var e=l.theme.getAttribute("href"),t=/[^\/]*?(?=\.css)/,n=e.match(t)[0];r.theme!==n&&(e=e.replace(t,r.theme),l.theme.setAttribute("href",e))}}function x(){document.addEventListener("touchstart",ft,!1),document.addEventListener("touchmove",lt,!1),document.addEventListener("touchend",ct,!1),window.addEventListener("hashchange",dt,!1),window.addEventListener("resize",vt,!1),r.keyboard&&document.addEventListener("keydown",at,!1),r.progress&&l.progress&&l.progress.addEventListener("click",A(pt),!1);if(r.controls&&l.controls){var e="ontouchstart"in window?"touchstart":"click";l.controlsLeft.forEach(function(t){t.addEventListener(e,A(nt),!1)}),l.controlsRight.forEach(function(t){t.addEventListener(e,A(rt),!1)}),l.controlsUp.forEach(function(t){t.addEventListener(e,A(it),!1)}),l.controlsDown.forEach(function(t){t.addEventListener(e,A(st),!1)}),l.controlsPrev.forEach(function(t){t.addEventListener(e,A(ot),!1)}),l.controlsNext.forEach(function(t){t.addEventListener(e,A(ut),!1)})}}function T(){document.removeEventListener("keydown",at,!1),document.removeEventListener("touchstart",ft,!1),document.removeEventListener("touchmove",lt,!1),document.removeEventListener("touchend",ct,!1),window.removeEventListener("hashchange",dt,!1),window.removeEventListener("resize",vt,!1),r.progress&&l.progress&&l.progress.removeEventListener("click",A(pt),!1);if(r.controls&&l.controls){var e="ontouchstart"in window?"touchstart":"click";l.controlsLeft.forEach(function(t){t.removeEventListener(e,A(nt),!1)}),l.controlsRight.forEach(function(t){t.removeEventListener(e,A(rt),!1)}),l.controlsUp.forEach(function(t){t.removeEventListener(e,A(it),!1)}),l.controlsDown.forEach(function(t){t.removeEventListener(e,A(st),!1)}),l.controlsPrev.forEach(function(t){t.removeEventListener(e,A(ot),!1)}),l.controlsNext.forEach(function(t){t.removeEventListener(e,A(ut),!1)})}}function N(e,t){for(var n in t)e[n]=t[n]}function C(e){return Array.prototype.slice.call(e)}function k(e,t,n){e.forEach(function(e){e[t].apply(e,n)})}function L(e,t){var n=e.x-t.x,r=e.y-t.y;return Math.sqrt(n*n+r*r)}function A(e){return function(t){t.preventDefault(),e.call(null,t)}}function O(){setTimeout(function(){window.scrollTo(0,1)},0)}functiLine truncated
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="<span></span>",l.wrapper.appendChild(e)}if(!l.wrapper.querySelector(".controls")&&r.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>',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;n++){var s=r.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 S(){b(),T(),x(),P(),G(),nt(),setTimeout(function(){_("ready",{indexh:s,indexv:o,currentSlide:a})},1)}function x(){c===!1&&(r.transition="linear"),r.controls&&l.controls&&(l.controls.style.display="block"),r.progress&&l.progress&&(l.progress.style.display="block"),r.transition!=="default"&&l.wrapper.classList.add(r.transition),r.rtl&&l.wrapper.classList.add("rtl"),r.center&&l.wrapper.classList.add("center"),r.mouseWheel&&(document.addEventListener("DOMMouseScroll",pt,!1),document.addEventListener("mousewheel",pt,!1)),r.rollingLinks&&D();if(r.theme&&l.theme){var e=l.theme.getAttribute("href"),t=/[^\/]*?(?=\.css)/,n=e.match(t)[0];r.theme!==n&&(e=e.replace(t,r.theme),l.theme.setAttribute("href",e))}}function T(){document.addEventListener("touchstart",lt,!1),document.addEventListener("touchmove",ct,!1),document.addEventListener("touchend",ht,!1),window.addEventListener("hashchange",vt,!1),window.addEventListener("resize",mt,!1),r.keyboard&&document.addEventListener("keydown",ft,!1),r.progress&&l.progress&&l.progress.addEventListener("click",O(dt),!1);if(r.controls&&l.controls){var e="ontouchstart"in window?"touchstart":"click";l.controlsLeft.forEach(function(t){t.addEventListener(e,O(rt),!1)}),l.controlsRight.forEach(function(t){t.addEventListener(e,O(it),!1)}),l.controlsUp.forEach(function(t){t.addEventListener(e,O(st),!1)}),l.controlsDown.forEach(function(t){t.addEventListener(e,O(ot),!1)}),l.controlsPrev.forEach(function(t){t.addEventListener(e,O(ut),!1)}),l.controlsNext.forEach(function(t){t.addEventListener(e,O(at),!1)})}}function N(){document.removeEventListener("keydown",ft,!1),document.removeEventListener("touchstart",lt,!1),document.removeEventListener("touchmove",ct,!1),document.removeEventListener("touchend",ht,!1),window.removeEventListener("hashchange",vt,!1),window.removeEventListener("resize",mt,!1),r.progress&&l.progress&&l.progress.removeEventListener("click",O(dt),!1);if(r.controls&&l.controls){var e="ontouchstart"in window?"touchstart":"click";l.controlsLeft.forEach(function(t){t.removeEventListener(e,O(rt),!1)}),l.controlsRight.forEach(function(t){t.removeEventListener(e,O(it),!1)}),l.controlsUp.forEach(function(t){t.removeEventListener(e,O(st),!1)}),l.controlsDown.forEach(function(t){t.removeEventListener(e,O(ot),!1)}),l.controlsPrev.forEach(function(t){t.removeEventListener(e,O(ut),!1)}),l.controlsNext.forEach(function(t){t.removeEventListener(e,O(at),!1)})}}function C(e,t){for(var n in t)e[n]=t[n]}function k(e){return Array.prototype.slice.call(e)}function L(e,t,n){e.forEach(function(e){e[t].apply(e,n)})}function A(e,t){var n=e.x-t.x,r=e.y-t.y;return Math.sqrt(n*n+r*r)}function O(e){return function(t){t.preventDefault(),e.call(null,t)}}function M(){setTimeout(function(){window.scrollTo(0,1)},0)}functiLine truncated