As someone not very up-to-date in Web UI techniques, I was curious as to how the array was being advanced on scroll. Unfortunately, it looks like the answer is basically polling. The code constantly calls window.requestAnimationFrame(), checking window.pageYOffset. This means that the page is constantly doing work, even at idle. Surely the more correct way is to install an onscroll handler or something, right?
The correct way would be a mix of those two strategies: an onscroll handler that schedules an update through requestAnimationFrame (ensuring that it only gets scheduled once until the next frame update actually executes).
Request animation frame exists specifically to avoid ‘traditional’ polling. You’re thinking more of setInterval() which is the old way of doing it. The requestAnimationFrame docs are a good read, there are lots of performance benefits.
Comments (124) 49 threads
https://emojipedia.org/milky-way/
https://emojipedia.org/microbe/
Continue this thread — 1 reply
https://emojipedia.org/atom-symbol/
Continue this thread — 3 replies
This is an open source project, so everyone commenting with suggestions can just open up a PR: https://github.com/javierbyte/emoji-to-scale
Only after I submitted did it occur to me that the size could be similar to the moon's
Continue this thread — 1 reply
As someone not very up-to-date in Web UI techniques, I was curious as to how the array was being advanced on scroll. Unfortunately, it looks like the answer is basically polling. The code constantly calls window.requestAnimationFrame(), checking window.pageYOffset. This means that the page is constantly doing work, even at idle.
Surely the more correct way is to install an onscroll handler or something, right?
Continue this thread — 1 reply
All comments shown.
Couldn't load more comments. Check your connection and try again.