I have a finger swipe js script with sessionStorage.
let touchstartX = 0;
let touchendX = 0;
function checkDirection() {
if (touchendX < touchstartX && !sessionStorage.getItem('firstTime')) {
window.location.href = '/';
sessionStorage.setItem('firstTime', 'true');
}
}
document.addEventListener('touchstart', (e) => {
touchstartX = e.changedTouches[0].screenX;
});
document.addEventListener('touchend', (e) => {
touchendX = e.changedTouches[0].screenX;
checkDirection();
});
What I need is to set this script activated on the home page just when you come back on it from other internal pages and not on the first homepage load.
Anyone has some suggestions, please? Thank you very much!