removing mobile swipe funcktionality
This commit is contained in:
@@ -691,70 +691,7 @@ window.requestAnimFrame = (function () {
|
||||
}
|
||||
// </infinite-scroll>
|
||||
|
||||
// <swipe>
|
||||
const swipeRT = {
|
||||
xDown: null,
|
||||
yDown: null,
|
||||
xDiff: null,
|
||||
yDiff: null,
|
||||
timeDown: null,
|
||||
startEl: null
|
||||
};
|
||||
const swipeOpt = {
|
||||
treshold: 20, // 20px
|
||||
timeout: 500 // 500ms
|
||||
};
|
||||
|
||||
document.addEventListener('touchstart', e => {
|
||||
swipeRT.startEl = e.target;
|
||||
swipeRT.timeDown = Date.now();
|
||||
swipeRT.xDown = e.touches[0].clientX;
|
||||
swipeRT.yDown = e.touches[0].clientY;
|
||||
swipeRT.xDiff = 0;
|
||||
swipeRT.yDiff = 0;
|
||||
}, false);
|
||||
|
||||
document.addEventListener('touchmove', e => {
|
||||
if (!swipeRT.xDown || !swipeRT.yDown)
|
||||
return;
|
||||
swipeRT.xDiff = swipeRT.xDown - e.touches[0].clientX;
|
||||
swipeRT.yDiff = swipeRT.yDown - e.touches[0].clientY;
|
||||
}, false);
|
||||
|
||||
document.addEventListener('touchend', e => {
|
||||
if (swipeRT.startEl !== e.target)
|
||||
return;
|
||||
|
||||
const timeDiff = Date.now() - swipeRT.timeDown;
|
||||
let elem;
|
||||
|
||||
if (Math.abs(swipeRT.xDiff) > Math.abs(swipeRT.yDiff)) {
|
||||
if (Math.abs(swipeRT.xDiff) > swipeOpt.treshold && timeDiff < swipeOpt.timeout) {
|
||||
if (swipeRT.xDiff > 0) // left
|
||||
elem = document.querySelector(".pagination > .next:not(.disabled)");
|
||||
else // right
|
||||
elem = document.querySelector(".pagination > .prev:not(.disabled)");
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (Math.abs(swipeRT.yDiff) > swipeOpt.treshold && timeDiff < swipeOpt.timeout) {
|
||||
if (navbar = document.querySelector("nav.navbar") && document.querySelector("div.posts")) {
|
||||
if (swipeRT.yDiff > 0 && (window.innerHeight + window.scrollY) >= document.body.offsetHeight) // up
|
||||
elem = document.querySelector(".pagination > .next:not(.disabled)");
|
||||
else if (swipeRT.yDiff <= 0 && window.scrollY <= 0 && document.querySelector("div.posts")) // down
|
||||
elem = document.querySelector(".pagination > .prev:not(.disabled)");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
swipeRT.xDown = null;
|
||||
swipeRT.yDown = null;
|
||||
swipeRT.timeDown = null;
|
||||
|
||||
if (elem)
|
||||
changePage(elem);
|
||||
}, false);
|
||||
// </swipe>
|
||||
|
||||
// <visualizer>
|
||||
if (audioElement = document.querySelector("audio")) {
|
||||
|
||||
Reference in New Issue
Block a user