Commit ec0d9e3d authored by Nikolay Gromov's avatar Nikolay Gromov

Закомментировал свайп оффканваса

parent e828e63e
......@@ -12,45 +12,45 @@ document.addEventListener('DOMContentLoaded', function(){
});
// реакция на свайп
document.addEventListener('touchstart', handleTouchStart, false);
document.addEventListener('touchmove', handleTouchMove, false);
var xDown = null;
var yDown = null;
function handleTouchStart(evt) {
xDown = evt.touches[0].clientX;
yDown = evt.touches[0].clientY;
};
function handleTouchMove(evt) {
if ( ! xDown || ! yDown ) {
return;
}
// document.addEventListener('touchstart', handleTouchStart, false);
// document.addEventListener('touchmove', handleTouchMove, false);
// var xDown = null;
// var yDown = null;
// function handleTouchStart(evt) {
// xDown = evt.touches[0].clientX;
// yDown = evt.touches[0].clientY;
// };
// function handleTouchMove(evt) {
// if ( ! xDown || ! yDown ) {
// return;
// }
var xUp = evt.touches[0].clientX;
var yUp = evt.touches[0].clientY;
// var xUp = evt.touches[0].clientX;
// var yUp = evt.touches[0].clientY;
var xDiff = xDown - xUp;
var yDiff = yDown - yUp;
if(Math.abs( xDiff )+Math.abs( yDiff )>100){ //to deal with to short swipes
// var xDiff = xDown - xUp;
// var yDiff = yDown - yUp;
// if(Math.abs( xDiff )+Math.abs( yDiff )>100){ //to deal with to short swipes
if ( Math.abs( xDiff ) > Math.abs( yDiff ) ) {/*most significant*/
if ( xDiff > 0 ) {/* left swipe */
document.getElementById('off-canvas').classList.remove('off-canvas--open');
} else {/* right swipe */
document.getElementById('off-canvas').classList.add('off-canvas--open');
}
}
// else {
// if ( yDiff > 0 ) {/* up swipe */
// alert('Up!');
// } else { /* down swipe */
// alert('Down!');
// if ( Math.abs( xDiff ) > Math.abs( yDiff ) ) {/*most significant*/
// if ( xDiff > 0 ) {/* left swipe */
// document.getElementById('off-canvas').classList.remove('off-canvas--open');
// } else {/* right swipe */
// document.getElementById('off-canvas').classList.add('off-canvas--open');
// }
// }
/* reset values */
xDown = null;
yDown = null;
}
};
// // else {
// // if ( yDiff > 0 ) {/* up swipe */
// // alert('Up!');
// // } else { /* down swipe */
// // alert('Down!');
// // }
// // }
// /* reset values */
// xDown = null;
// yDown = null;
// }
// };
function offCanvasToggle() {
document.getElementById('off-canvas').classList.toggle('off-canvas--open');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment