circumvent browser bug for scroll component

This commit is contained in:
2024-09-10 09:31:40 +02:00
parent d3e6f68fdf
commit f4ae51623f

View File

@@ -29,14 +29,8 @@ window.scrollHint = ( maxScroll ) => {
timeout = setTimeout( () => { showHint() }, 2500 ); timeout = setTimeout( () => { showHint() }, 2500 );
} }
document.onscrollend = () => { let lastScrollTimeStamp = new Date().getTime();
scrollCorrectionTimeout = setTimeout( () => { let scrollInterval = 0;
scrollCorrection();
}, 1000 );
timeout = setTimeout( () => {
showHint();
}, 2500 );
}
document.onscroll = () => { document.onscroll = () => {
try { try {
clearTimeout( timeout ); clearTimeout( timeout );
@@ -49,6 +43,25 @@ window.scrollHint = ( maxScroll ) => {
el.classList.remove( 'show-scroll' ); el.classList.remove( 'show-scroll' );
el.classList.add( 'hide-scroll' ); el.classList.add( 'hide-scroll' );
} }
if ( scrollInterval === 0 ) {
scrollInterval = setInterval( () => {
if ( lastScrollTimeStamp < new Date().getTime() + 500 ) {
scrollCorrectionTimeout = setTimeout( () => {
scrollCorrection();
}, 1000 );
timeout = setTimeout( () => {
showHint();
}, 2500 );
try {
clearInterval( scrollInterval );
scrollInterval = 0;
} catch ( e ) { /* empty */ }
}
}, 250 );
}
lastScrollTimeStamp = new Date().getTime();
}; };
window.onresize = () => { window.onresize = () => {