News for hackers. Stuff that matters.
Re:Show HN: Magic Grid – A simple JavaScript library for dyn... by Eli_P on Monday December 24, 2018 @11:39AM (#18752874)
Correct me if I'm wrong, but using window.addEventListener("resize", () => (), 200) is no good, you probably should consider window.requestAnimationFrame() and debouncing. Otherwise, your library will drain battery juice, despite it's really lightweight. Say, on Android, actions like typing into an input field, changing orientation, scrolling backward and triggering url bar appearing, all of them do trigger costly document reflow.
Re:Show HN: Magic Grid – A simple JavaScript library for dyn... by e-oj on Monday December 24, 2018 @11:51AM (#18752945)
You're right requestAnimationFrame is more efficient than using the resize listener with a delay. I'm actually working on an update to change that. It'll be fixed soon.