enable pinch to zoom interaction if overview is disabled (#175)
This commit is contained in:
parent
6e0d0e279d
commit
86a907e8cc
16
js/reveal.js
16
js/reveal.js
|
@ -102,7 +102,7 @@ var Reveal = (function(){
|
|||
startSpan: 0,
|
||||
startCount: 0,
|
||||
handled: false,
|
||||
threshold: 40
|
||||
threshold: 80
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -471,7 +471,7 @@ var Reveal = (function(){
|
|||
|
||||
// If there's two touches we need to memorize the distance
|
||||
// between those two points to detect pinching
|
||||
if( event.touches.length === 2 ) {
|
||||
if( event.touches.length === 2 && config.overview ) {
|
||||
touch.startSpan = distanceBetween( {
|
||||
x: event.touches[1].clientX,
|
||||
y: event.touches[1].clientY
|
||||
|
@ -493,7 +493,7 @@ var Reveal = (function(){
|
|||
|
||||
// If the touch started off with two points and still has
|
||||
// two active touches; test for the pinch gesture
|
||||
if( event.touches.length === 2 && touch.startCount === 2 ) {
|
||||
if( event.touches.length === 2 && touch.startCount === 2 && config.overview ) {
|
||||
|
||||
// The current distance in pixels between the two touch points
|
||||
var currentSpan = distanceBetween( {
|
||||
|
@ -517,9 +517,12 @@ var Reveal = (function(){
|
|||
}
|
||||
}
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
}
|
||||
// There was only one touch point, look for a swipe
|
||||
else if( event.touches.length === 1 ) {
|
||||
else if( event.touches.length === 1 && touch.startCount !== 2 ) {
|
||||
|
||||
var deltaX = currentX - touch.startX,
|
||||
deltaY = currentY - touch.startY;
|
||||
|
||||
|
@ -539,9 +542,10 @@ var Reveal = (function(){
|
|||
touch.handled = true;
|
||||
navigateDown();
|
||||
}
|
||||
}
|
||||
|
||||
event.preventDefault();
|
||||
event.preventDefault();
|
||||
|
||||
}
|
||||
}
|
||||
// There's a bug with swiping on some Android devices unless
|
||||
// the default action is always prevented
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*
|
||||
* Copyright (C) 2011-2012 Hakim El Hattab, http://hakim.se
|
||||
*/
|
||||
var Reveal=(function(){var l=".reveal .slides>section",b=".reveal .slides>section.present>section",R={controls:true,progress:true,history:false,keyboard:true,overview:true,loop:false,autoSlide:0,mouseWheel:true,rollingLinks:true,theme:null,transition:"default",dependencies:[]},Y=R.autoSlide,m=0,e=0,y,G,ai=[],f={},T="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,n="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,z=0,k=0,D=0,ab={startX:0,startY:0,startSpan:0,startCount:0,handled:false,threshold:40};
|
||||
var Reveal=(function(){var l=".reveal .slides>section",b=".reveal .slides>section.present>section",R={controls:true,progress:true,history:false,keyboard:true,overview:true,loop:false,autoSlide:0,mouseWheel:true,rollingLinks:true,theme:null,transition:"default",dependencies:[]},Y=R.autoSlide,m=0,e=0,y,G,ai=[],f={},T="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,n="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,z=0,k=0,D=0,ab={startX:0,startY:0,startSpan:0,startCount:0,handled:false,threshold:80};
|
||||
function i(aj){if((!n&&!T)){document.body.setAttribute("class","no-transforms");return;}t(R,aj);P();d();V();}function P(){f.theme=document.querySelector("#theme");
|
||||
f.wrapper=document.querySelector(".reveal");if(!f.wrapper.querySelector(".progress")&&R.progress){var am=document.createElement("div");am.classList.add("progress");
|
||||
am.innerHTML="<span></span>";f.wrapper.appendChild(am);}if(!f.wrapper.querySelector(".controls")&&R.controls){var al=document.createElement("aside");al.classList.add("controls");
|
||||
|
@ -33,11 +33,11 @@ t(al,aj);f.wrapper.dispatchEvent(al);}function ag(ak){if(document.querySelector(
|
|||
}var aj=true;switch(ak.keyCode){case 80:case 33:Z();break;case 78:case 34:x();break;case 72:case 37:B();break;case 76:case 39:j();break;case 75:case 38:u();
|
||||
break;case 74:case 40:F();break;case 36:O(0);break;case 35:O(Number.MAX_VALUE);break;case 32:L()?ad():x();break;case 13:L()?ad():aj=false;break;case 66:case 190:aa();
|
||||
break;default:aj=false;}if(aj){ak.preventDefault();}else{if(ak.keyCode===27&&T){X();ak.preventDefault();}}N();}function A(aj){ab.startX=aj.touches[0].clientX;
|
||||
ab.startY=aj.touches[0].clientY;ab.startCount=aj.touches.length;if(aj.touches.length===2){ab.startSpan=S({x:aj.touches[1].clientX,y:aj.touches[1].clientY},{x:ab.startX,y:ab.startY});
|
||||
}}function ae(ao){if(!ab.handled){var am=ao.touches[0].clientX;var al=ao.touches[0].clientY;if(ao.touches.length===2&&ab.startCount===2){var an=S({x:ao.touches[1].clientX,y:ao.touches[1].clientY},{x:ab.startX,y:ab.startY});
|
||||
if(Math.abs(ab.startSpan-an)>ab.threshold){ab.handled=true;if(an<ab.startSpan){I();}else{ad();}}}else{if(ao.touches.length===1){var ak=am-ab.startX,aj=al-ab.startY;
|
||||
ab.startY=aj.touches[0].clientY;ab.startCount=aj.touches.length;if(aj.touches.length===2&&R.overview){ab.startSpan=S({x:aj.touches[1].clientX,y:aj.touches[1].clientY},{x:ab.startX,y:ab.startY});
|
||||
}}function ae(ao){if(!ab.handled){var am=ao.touches[0].clientX;var al=ao.touches[0].clientY;if(ao.touches.length===2&&ab.startCount===2&&R.overview){var an=S({x:ao.touches[1].clientX,y:ao.touches[1].clientY},{x:ab.startX,y:ab.startY});
|
||||
if(Math.abs(ab.startSpan-an)>ab.threshold){ab.handled=true;if(an<ab.startSpan){I();}else{ad();}}ao.preventDefault();}else{if(ao.touches.length===1&&ab.startCount!==2){var ak=am-ab.startX,aj=al-ab.startY;
|
||||
if(ak>ab.threshold&&Math.abs(ak)>Math.abs(aj)){ab.handled=true;B();}else{if(ak<-ab.threshold&&Math.abs(ak)>Math.abs(aj)){ab.handled=true;j();}else{if(aj>ab.threshold){ab.handled=true;
|
||||
u();}else{if(aj<-ab.threshold){ab.handled=true;F();}}}}}}ao.preventDefault();}else{if(navigator.userAgent.match(/android/gi)){ao.preventDefault();}}}function W(aj){ab.handled=false;
|
||||
u();}else{if(aj<-ab.threshold){ab.handled=true;F();}}}}ao.preventDefault();}}}else{if(navigator.userAgent.match(/android/gi)){ao.preventDefault();}}}function W(aj){ab.handled=false;
|
||||
}function p(aj){clearTimeout(z);z=setTimeout(function(){var ak=aj.detail||-aj.wheelDelta;if(ak>0){x();}else{Z();}},100);}function w(aj){J();}function C(aj){if(L()){aj.preventDefault();
|
||||
ad();m=this.getAttribute("data-index-h");e=this.getAttribute("data-index-v");a();}}function M(){if(T&&!("msPerspective" in document.body.style)){var ak=document.querySelectorAll(".reveal .slides section a:not(.image)");
|
||||
for(var al=0,aj=ak.length;al<aj;al++){var am=ak[al];if(am.textContent&&!am.querySelector("img")&&(!am.className||!am.classList.contains(am,"roll"))){am.classList.add("roll");
|
||||
|
|
Loading…
Reference in New Issue