inputs :
events :
expected result :
actual result :
I did try to do "overflow:hidden" on the "body" during the animation, but this does not cancel the scroll event, which still continues to scroll the page after the animation of the automatic scroll is completed (specifically using a laptop trackpad).
Any ideas ? Thx !
PS: I would appreciate native javascript answers please.
You could use window.pageYOffset
Here is an example: The code within the if statement only runs within the first 100px from top of the page
window.addEventListener("scroll", function(){
if(window.pageYOffset < 100) {
console.log("hi there");
}
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.