fuck you sirx
This commit is contained in:
parent
e56cf37f61
commit
346574887b
@ -60,16 +60,33 @@
|
|||||||
// </image-responsive>
|
// </image-responsive>
|
||||||
|
|
||||||
// <scroller>
|
// <scroller>
|
||||||
|
let tts = 0;
|
||||||
if(document.querySelector("div#posts")) {
|
if(document.querySelector("div#posts")) {
|
||||||
document.addEventListener("wheel", e => {
|
document.addEventListener("wheel", e => {
|
||||||
if((window.innerHeight + window.scrollY) >= document.body.offsetHeight && e.deltaY > 0) {
|
if((window.innerHeight + window.scrollY) >= document.body.offsetHeight && e.deltaY > 0) { // down
|
||||||
if(elem = document.querySelector(".pagination > .next:not(.disabled)"))
|
if(elem = document.querySelector(".pagination > .next:not(.disabled)")) {
|
||||||
|
if(tts < 2) {
|
||||||
|
document.querySelector("div#footbar").style.backgroundColor = "var(--scroller-bg)";
|
||||||
|
tts++;
|
||||||
|
}
|
||||||
|
else
|
||||||
changePage(elem);
|
changePage(elem);
|
||||||
}
|
}
|
||||||
else if(window.scrollY <= 0 && e.deltaY < 0) {
|
}
|
||||||
if(elem = document.querySelector(".pagination > .prev:not(.disabled)"))
|
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);
|
changePage(elem);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
document.querySelector("div#footbar").style.backgroundColor = "var(--nav-bg)";
|
||||||
|
document.querySelector("nav.navbar").style.backgroundColor = "var(--nav-bg)";
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,45 +97,67 @@
|
|||||||
// </scroller>
|
// </scroller>
|
||||||
|
|
||||||
// <swipe>
|
// <swipe>
|
||||||
let lastTap = 0;
|
const swipeRT = {
|
||||||
let xDown = null;
|
xDown: null,
|
||||||
let yDown = null;
|
yDown: null,
|
||||||
document.addEventListener('touchstart', e => {
|
xDiff: null,
|
||||||
const firstTouch = (e.touches ?? e.originalEvent.touches)[0];
|
yDiff: null,
|
||||||
xDown = firstTouch.clientX;
|
timeDown: null,
|
||||||
yDown = firstTouch.clientY;
|
startEl: null
|
||||||
|
};
|
||||||
|
const swipeOpt = {
|
||||||
|
treshold: 20, // 20px
|
||||||
|
timeout: 500 // 500ms
|
||||||
|
};
|
||||||
|
|
||||||
const currentTime = new Date().getTime();
|
document.addEventListener('touchstart', e => {
|
||||||
const tapLength = currentTime - lastTap;
|
swipeRT.startEl = e.target;
|
||||||
if(tapLength < 500 && tapLength > 0)
|
swipeRT.timeDown = Date.now();
|
||||||
if(elem = document.querySelector("#random"))
|
swipeRT.xDown = e.touches[0].clientX;
|
||||||
changePage(elem);
|
swipeRT.yDown = e.touches[0].clientY;
|
||||||
lastTap = currentTime;
|
swipeRT.xDiff = 0;
|
||||||
|
swipeRT.yDiff = 0;
|
||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
document.addEventListener('touchmove', e => {
|
document.addEventListener('touchmove', e => {
|
||||||
if(!xDown || !yDown)
|
if(!swipeRT.xDown || !swipeRT.yDown)
|
||||||
return;
|
return;
|
||||||
const xDiff = xDown - e.touches[0].clientX;
|
swipeRT.xDiff = swipeRT.xDown - e.touches[0].clientX;
|
||||||
const yDiff = yDown - e.touches[0].clientY;
|
swipeRT.yDiff = swipeRT.yDown - e.touches[0].clientY;
|
||||||
let elem = false;
|
}, false);
|
||||||
if(Math.abs(xDiff) > Math.abs(yDiff)) {
|
|
||||||
if(xDiff > 0) // left
|
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)");
|
elem = document.querySelector(".pagination > .next:not(.disabled)");
|
||||||
else // right
|
else // right
|
||||||
elem = document.querySelector(".pagination > .prev:not(.disabled)");
|
elem = document.querySelector(".pagination > .prev:not(.disabled)");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
|
if(Math.abs(swipeRT.yDiff) > swipeOpt.treshold && timeDiff < swipeOpt.timeout) {
|
||||||
if(navbar = document.querySelector("nav.navbar") && document.querySelector("div#posts")) {
|
if(navbar = document.querySelector("nav.navbar") && document.querySelector("div#posts")) {
|
||||||
if(yDiff > 0 && (window.innerHeight + window.scrollY) >= document.body.offsetHeight) // up
|
if(swipeRT.yDiff > 0 && (window.innerHeight + window.scrollY) >= document.body.offsetHeight) // up
|
||||||
elem = document.querySelector(".pagination > .next:not(.disabled)");
|
elem = document.querySelector(".pagination > .next:not(.disabled)");
|
||||||
else if(yDiff <= 0 && window.scrollY <= 0 && document.querySelector("div#posts")) // down
|
else if(swipeRT.yDiff <= 0 && window.scrollY <= 0 && document.querySelector("div#posts")) // down
|
||||||
elem = document.querySelector(".pagination > .prev:not(.disabled)");
|
elem = document.querySelector(".pagination > .prev:not(.disabled)");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
swipeRT.xDown = null;
|
||||||
|
swipeRT.yDown = null;
|
||||||
|
swipeRT.timeDown = null;
|
||||||
|
|
||||||
if(elem)
|
if(elem)
|
||||||
changePage(elem);
|
changePage(elem);
|
||||||
xDown = yDown = null;
|
|
||||||
}, false);
|
}, false);
|
||||||
// </swipe>
|
// </swipe>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user