diff --git a/public/s/js/f0ck.js b/public/s/js/f0ck.js
index e7fbe49..a549368 100644
--- a/public/s/js/f0ck.js
+++ b/public/s/js/f0ck.js
@@ -60,15 +60,32 @@
//
//
+ let tts = 0;
if(document.querySelector("div#posts")) {
document.addEventListener("wheel", e => {
- if((window.innerHeight + window.scrollY) >= document.body.offsetHeight && e.deltaY > 0) {
- if(elem = document.querySelector(".pagination > .next:not(.disabled)"))
- changePage(elem);
+ if((window.innerHeight + window.scrollY) >= document.body.offsetHeight && e.deltaY > 0) { // down
+ if(elem = document.querySelector(".pagination > .next:not(.disabled)")) {
+ if(tts < 2) {
+ document.querySelector("div#footbar").style.backgroundColor = "var(--scroller-bg)";
+ tts++;
+ }
+ else
+ changePage(elem);
+ }
}
- else if(window.scrollY <= 0 && e.deltaY < 0) {
- if(elem = document.querySelector(".pagination > .prev:not(.disabled)"))
- changePage(elem);
+ else if(window.scrollY <= 0 && e.deltaY < 0) { // up
+ if(elem = document.querySelector(".pagination > .prev:not(.disabled)")) {
+ if(tts < 2) {
+ document.querySelector("nav.navbar").style.backgroundColor = "var(--scroller-bg)";
+ tts++;
+ }
+ else
+ changePage(elem);
+ }
+ }
+ else {
+ document.querySelector("div#footbar").style.backgroundColor = "var(--nav-bg)";
+ document.querySelector("nav.navbar").style.backgroundColor = "var(--nav-bg)";
}
});
}
@@ -78,47 +95,69 @@
if(document.location.href.match(rmatch) < document.referrer.match(rmatch))
document.body.scrollTop = document.body.scrollHeight;
//
-
+
//
- let lastTap = 0;
- let xDown = null;
- let yDown = null;
- document.addEventListener('touchstart', e => {
- const firstTouch = (e.touches ?? e.originalEvent.touches)[0];
- xDown = firstTouch.clientX;
- yDown = firstTouch.clientY;
+ const swipeRT = {
+ xDown: null,
+ yDown: null,
+ xDiff: null,
+ yDiff: null,
+ timeDown: null,
+ startEl: null
+ };
+ const swipeOpt = {
+ treshold: 20, // 20px
+ timeout: 500 // 500ms
+ };
- const currentTime = new Date().getTime();
- const tapLength = currentTime - lastTap;
- if(tapLength < 500 && tapLength > 0)
- if(elem = document.querySelector("#random"))
- changePage(elem);
- lastTap = currentTime;
+ 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(!xDown || !yDown)
+ if(!swipeRT.xDown || !swipeRT.yDown)
return;
- const xDiff = xDown - e.touches[0].clientX;
- const yDiff = yDown - e.touches[0].clientY;
- let elem = false;
- if(Math.abs(xDiff) > Math.abs(yDiff)) {
- if(xDiff > 0) // left
- elem = document.querySelector(".pagination > .next:not(.disabled)");
- else // right
- elem = document.querySelector(".pagination > .prev:not(.disabled)");
- }
- else {
- if(navbar = document.querySelector("nav.navbar") && document.querySelector("div#posts")) {
- if(yDiff > 0 && (window.innerHeight + window.scrollY) >= document.body.offsetHeight) // up
+ 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 if(yDiff <= 0 && window.scrollY <= 0 && document.querySelector("div#posts")) // down
+ 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);
- xDown = yDown = null;
}, false);
//