fuck you sirx
This commit is contained in:
parent
e56cf37f61
commit
346574887b
@ -60,15 +60,32 @@
|
|||||||
// </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)")) {
|
||||||
changePage(elem);
|
if(tts < 2) {
|
||||||
|
document.querySelector("div#footbar").style.backgroundColor = "var(--scroller-bg)";
|
||||||
|
tts++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
changePage(elem);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if(window.scrollY <= 0 && e.deltaY < 0) {
|
else if(window.scrollY <= 0 && e.deltaY < 0) { // up
|
||||||
if(elem = document.querySelector(".pagination > .prev:not(.disabled)"))
|
if(elem = document.querySelector(".pagination > .prev:not(.disabled)")) {
|
||||||
changePage(elem);
|
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))
|
if(document.location.href.match(rmatch) < document.referrer.match(rmatch))
|
||||||
document.body.scrollTop = document.body.scrollHeight;
|
document.body.scrollTop = document.body.scrollHeight;
|
||||||
// </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 => {
|
||||||
elem = document.querySelector(".pagination > .next:not(.disabled)");
|
if(swipeRT.startEl !== e.target)
|
||||||
else // right
|
return;
|
||||||
elem = document.querySelector(".pagination > .prev:not(.disabled)");
|
|
||||||
}
|
const timeDiff = Date.now() - swipeRT.timeDown;
|
||||||
else {
|
let elem;
|
||||||
if(navbar = document.querySelector("nav.navbar") && document.querySelector("div#posts")) {
|
|
||||||
if(yDiff > 0 && (window.innerHeight + window.scrollY) >= document.body.offsetHeight) // up
|
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 if(yDiff <= 0 && window.scrollY <= 0 && document.querySelector("div#posts")) // down
|
else // right
|
||||||
elem = document.querySelector(".pagination > .prev:not(.disabled)");
|
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)
|
if(elem)
|
||||||
changePage(elem);
|
changePage(elem);
|
||||||
xDown = yDown = null;
|
|
||||||
}, false);
|
}, false);
|
||||||
// </swipe>
|
// </swipe>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user