3 ms·
It seems that querying the screen position is just a heuristic they came up with to determine the nature of the event. Instinctively I would use instance of Mou
by whstl 2y ago
It seems that querying the screen position is just a heuristic they came up with to determine the nature of the event. Instinctively I would use instance of MouseEvent for this, but even this feels risky/hacky to me.
My question is why they're relying on those heuristics. My guess is that toggleMenu is being used by multiple event handlers. Or maybe there's something else going on that is specific to their codebase.
It's hard to judge without knowing the full picture.
EDIT: Aha, there's an answer here: https://news.ycombinator.com/item?id=42174177 https://news.ycombinator.com/item?id=42174177
- alain94040 2y agoYou can do a search on GitHub and there is quite a bit of code that is using event.screenX > 0. Maybe someone should file some bug reports. Also, stack overflow suggests that exact code to "differentiate between mouse and keyboard triggering onclick": https://stackoverflow.com/questions/7465006/differentiate-between-mouse-and-keyboard-triggering-onclick https://stackoverflow.com/questions/7465006/differentiate-be...