Good concept, i wonder if there is a better way to do this other than to forEach all elements twice on every scroll.
Adding a throttle will help. The amount of executions the above is making is a crazy amount per scroll.
*update: i did some performance benchmarks, it looks like using throttle or debounce is less performant than letting the function run on every scroll.
I opened an issue here for informational purposes: github.com/niksy/throttle-debounce...
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Good concept, i wonder if there is a better way to do this other than to forEach all elements twice on every scroll.
Adding a throttle will help. The amount of executions the above is making is a crazy amount per scroll.
*update: i did some performance benchmarks, it looks like using throttle or debounce is less performant than letting the function run on every scroll.
I opened an issue here for informational purposes:
github.com/niksy/throttle-debounce...