Today I've got kind of theoretical question. Why does scroll event not bubble? Is it connected with performance issues? I did some digging, but unfortunately didn't find any answers that would fulfill my curiosity.
Thanks for your replies :)
The scroll event does not bubble up. Although the event does not bubble, browsers fire a scroll event on both document and window when the user scrolls the entire page.
forEach(element => { window. addEventListener( "scroll", () => runOnScroll(element), { passive: true } ); }); Or alternatively, bind a single scroll listener, with evt => runOnScroll(evt) as handler and then figure out what to do with everything in elements inside the runOnScroll function instead.
jQuery Mobile provides two scroll events: when scrolling starts and when scrolling stops.
It bubbles but not on elements. It bubbles at the document object up to document.defaultView (window of the document). This behavior happens to avoid performance issues (scroll events can fire at a high rate).
If you want to learn more about scrolling I would suggest reading the W3 documentation:
https://www.w3.org/TR/cssom-view/#scrolling
I hope it helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With