on ajoute un seuil

This commit is contained in:
Christophe 2019-01-31 14:10:01 +01:00
parent 043b9494d0
commit 6a1b874ca8

View file

@ -6,6 +6,7 @@
function gamuSwipe(mon_id,handleswipe){
window.addEventListener('load', function(){
var touchsurface = document.getElementById(mon_id);
var seuil = 150;
var startX;
var dist;
@ -21,12 +22,14 @@ function gamuSwipe(mon_id,handleswipe){
touchsurface.addEventListener('touchend', function(e){
var touchobj = e.changedTouches[0];
dist = touchobj.pageX - startX;
if (dist < 0) {
handleswipe('left');
e.preventDefault();
} else if(dist > 0){
handleswipe('right');
e.preventDefault();
if (Math.abs(dist) > seuil ) {
if (dist < 0) {
handleswipe('left');
e.preventDefault();
} else if(dist > 0){
handleswipe('right');
e.preventDefault();
}
}
}, false);