remove gesture swipes

master
Aevann 2024-01-15 15:50:20 +02:00
parent 788afc3df7
commit 49d1946eca
1 changed files with 1 additions and 85 deletions

View File

@ -34,16 +34,7 @@ if (fake_textarea) {
}
//SWIPING AND KEYBOARD ARROWS
//KEYBOARD ARROW NAVIGATION
const post_ids = localStorage.getItem("post_ids").split(', ');
const current_index = post_ids.indexOf(`'${location.href}'`)
@ -61,79 +52,4 @@ if (current_index > -1) {
}
}
})
if (screen_width < 768) {
const _C = document.querySelector('.container')
const N = _C.children.length
const NF = 30
let i = 0, x0 = null, y0 = null, locked = false, w, ini, fin, anf, n;
function unify(e) { return e.changedTouches ? e.changedTouches[0] : e };
function lock(e) {
x0 = unify(e).clientX;
y0 = unify(e).clientY;
locked = true
};
function drag(e) {
if(locked) {
let dx = unify(e).clientX - x0
let f = +(dx/w).toFixed(2);
let dy = unify(e).clientY - y0
let fy = +(dy/y).toFixed(2);
if (!getSelection().toString() && (f > 0.04 || f < -0.04) && (fy < 0.03 && fy > -0.03)) {
if (id_before && f > 0.2) {
location.href = id_before.slice(1, -1)
}
if (id_after && f < -0.2) {
location.href = id_after.slice(1, -1)
}
}
}
};
function move(e) {
if(locked) {
let dx = unify(e).clientX - x0,
s = Math.sign(dx),
f = +(s*dx/w).toFixed(2);
ini = i - s*f;
if((i > 0 || s < 0) && (i < N - 1 || s > 0) && f > .2) {
i -= s;
f = 1 - f
}
fin = i;
anf = Math.round(f*NF);
n = 2 + Math.round(f)
x0 = null;
y0 = null;
locked = false;
}
};
function size() {
w = window.innerWidth
y = window.innerHeight
};
size();
addEventListener('resize', size, false);
_C.addEventListener('mousedown', lock, false);
_C.addEventListener('touchstart', lock, false);
_C.addEventListener('mousemove', drag, false);
_C.addEventListener('touchmove', drag, false);
_C.addEventListener('mouseup', move, false);
_C.addEventListener('touchend', move, false);
}
}