readding script.js
This commit is contained in:
@@ -0,0 +1,55 @@
|
|||||||
|
let startX;
|
||||||
|
|
||||||
|
document.addEventListener('touchstart', function(event) {
|
||||||
|
if (event.touches.length > 1) {
|
||||||
|
event.preventDefault();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
startX = event.touches[0].clientX; // Get the starting X position
|
||||||
|
});
|
||||||
|
|
||||||
|
document.addEventListener('touchmove', function(event) {
|
||||||
|
if (event.touches.length > 1) {
|
||||||
|
event.preventDefault();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const moveX = event.touches[0].clientX; // Get the current X position
|
||||||
|
const diffX = startX - moveX; // Calculate the difference
|
||||||
|
|
||||||
|
if (Math.abs(diffX) > 100) { // Check if the swipe is significant
|
||||||
|
document.getElementsByClassName("itemlist")[0].classList.add(diffX > 0 ? 'swipe-left' : 'swipe-right');
|
||||||
|
document.getElementsByClassName("itemlist")[1].classList.add(diffX > 0 ? 'swipe-left' : 'swipe-right');
|
||||||
|
try {
|
||||||
|
document.getElementsByClassName("itemlist")[2].classList.add(diffX > 0 ? 'swipe-left' : 'swipe-right');
|
||||||
|
} catch(err) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
if (diffX > 0) {
|
||||||
|
if (currentPage < (maxpages)) {
|
||||||
|
window.location.href = './' + nextpage;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (currentPage > 1) {
|
||||||
|
window.location.href = './' + prevpage;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 500);
|
||||||
|
event.preventDefault();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
document.addEventListener('transitionend', function() {
|
||||||
|
setTimeout(()=> {
|
||||||
|
document.getElementsByClassName("itemlist")[0].classList.remove('swipe-left', 'swipe-right');
|
||||||
|
document.getElementsByClassName("itemlist")[1].classList.remove('swipe-left', 'swipe-right');
|
||||||
|
|
||||||
|
try {
|
||||||
|
document.getElementsByClassName("itemlist")[2].classList.remove('swipe-left', 'swipe-right');
|
||||||
|
} catch(err) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}, 300);
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user