You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1.4 KiB
JavaScript
40 lines
1.4 KiB
JavaScript
3 weeks ago
|
let initialScrollDone = false;
|
||
|
|
||
|
window.addEventListener('wheel', (e) => {
|
||
|
if (!initialScrollDone && e.deltaY > 0) {
|
||
|
// Only trigger on initial downward scroll
|
||
|
e.preventDefault();
|
||
|
window.scrollTo({
|
||
|
top: window.innerHeight,
|
||
|
behavior: 'smooth'
|
||
|
});
|
||
|
initialScrollDone = true;
|
||
|
// Enable normal scrolling after a short delay
|
||
|
setTimeout(() => {
|
||
|
document.body.style.overflow = 'auto';
|
||
|
}, 10);
|
||
|
}
|
||
|
});
|
||
|
|
||
|
// Touch handling for mobile devices
|
||
|
let startY;
|
||
|
window.addEventListener('touchstart', (e) => {
|
||
|
startY = e.touches[0].clientY;
|
||
|
});
|
||
|
|
||
|
window.addEventListener('touchmove', (e) => {
|
||
|
const currentY = e.touches[0].clientY;
|
||
|
if (!initialScrollDone && currentY < startY) {
|
||
|
// Only trigger on initial upward touch move
|
||
|
e.preventDefault();
|
||
|
window.scrollTo({
|
||
|
top: window.innerHeight,
|
||
|
behavior: 'smooth'
|
||
|
});
|
||
|
initialScrollDone = true;
|
||
|
// Enable normal scrolling after a short delay
|
||
|
setTimeout(() => {
|
||
|
document.body.style.overflow = 'auto';
|
||
|
}, 10);
|
||
|
}
|
||
|
});
|