fixed bug in swipe gesture interacting with links.
parent
2e024b5b3e
commit
049880dba3
33
js/reveal.js
33
js/reveal.js
|
@ -26,7 +26,7 @@ var Reveal = (function(){
|
||||||
rollingLinks: true,
|
rollingLinks: true,
|
||||||
transition: 'default',
|
transition: 'default',
|
||||||
theme: 'default',
|
theme: 'default',
|
||||||
swipeDistance: 30
|
swipeDist: 30
|
||||||
},
|
},
|
||||||
|
|
||||||
// Slides may hold a data-state attribute which we pick up and apply
|
// Slides may hold a data-state attribute which we pick up and apply
|
||||||
|
@ -241,21 +241,14 @@ var Reveal = (function(){
|
||||||
var touchStart = {}
|
var touchStart = {}
|
||||||
var gesture = false;
|
var gesture = false;
|
||||||
function onDocumentTouchStart( event ) {
|
function onDocumentTouchStart( event ) {
|
||||||
// We're only interested in one point taps
|
|
||||||
if (event.touches.length === 1) {
|
|
||||||
// Never prevent taps on anchors and images
|
|
||||||
if( event.target.tagName.toLowerCase() === 'a' || event.target.tagName.toLowerCase() === 'img' ) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
event.preventDefault();
|
|
||||||
|
|
||||||
touchStart = {
|
touchStart = {
|
||||||
x: event.touches[0].clientX,
|
x: event.touches[0].clientX,
|
||||||
y: event.touches[0].clientY
|
y: event.touches[0].clientY
|
||||||
};
|
};
|
||||||
|
if( event.target.tagName.toLowerCase() === 'a' || event.target.tagName.toLowerCase() === 'img' ) {
|
||||||
slide();
|
} else {
|
||||||
|
event.preventDefault();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -268,26 +261,27 @@ var Reveal = (function(){
|
||||||
x: event.touches[0].clientX,
|
x: event.touches[0].clientX,
|
||||||
y: event.touches[0].clientY
|
y: event.touches[0].clientY
|
||||||
};
|
};
|
||||||
if((touch.x - touchStart.x) > config.swipeDistance){
|
if((touch.x - touchStart.x) > config.swipeDist){
|
||||||
gesture = true;
|
gesture = true;
|
||||||
navigateLeft();
|
navigateLeft();
|
||||||
} else if((touch.x - touchStart.x) < -config.swipeDistance){
|
} else if((touch.x - touchStart.x) < -config.swipeDist){
|
||||||
gesture = true;
|
gesture = true;
|
||||||
navigateRight();
|
navigateRight();
|
||||||
} else if((touch.y - touchStart.y) > config.swipeDistance){
|
} else if((touch.y - touchStart.y) > config.swipeDist){
|
||||||
gesture = true;
|
gesture = true;
|
||||||
navigateUp();
|
navigateUp();
|
||||||
} else if((touch.y - touchStart.y) < -config.swipeDistance){
|
} else if((touch.y - touchStart.y) < -config.swipeDist){
|
||||||
gesture = true;
|
gesture = true;
|
||||||
navigateDown();
|
navigateDown();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function onDocumentTouchEnd( event ) {
|
function onDocumentTouchEnd( event ) {
|
||||||
|
if(!gesture){
|
||||||
event.preventDefault();
|
// Never prevent taps on anchors and images
|
||||||
|
if( event.target.tagName.toLowerCase() === 'a' || event.target.tagName.toLowerCase() === 'img' ) {
|
||||||
if(!gesture){//only check for control tap if no gesture is performed
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Define the extent of the areas that may be tapped
|
// Define the extent of the areas that may be tapped
|
||||||
// to navigate
|
// to navigate
|
||||||
|
@ -308,6 +302,7 @@ var Reveal = (function(){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
gesture = false;
|
gesture = false;
|
||||||
|
event.preventDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue