Hacker News new | ask | show | jobs
by pimlottc 3533 days ago
> Ever spent a frustrating hour debugging a broken mouseup event, until you realised that it’s because the user is letting go of the button outside your click target? No? Okay, maybe it’s just me, then.

I hope no one uses this example to make an onClick action that works no matter where the pointer is when the button is released. The correct behavior when this happens is to ignore the click when the user has moved off the click target when the button is released. It's a pretty handy convention, as it's the only way to for a user to "abort" a click once they start it - something I've done a few times myself.

This example pattern could be useful, though, in managing the UI state when something like this occurs.

1 comments

The problem, as I understand it, is in order for a UI to feel responsive you often have to start reacting to the mousedown/mousemove before the mouseup occurs. So you need to do some cleanup when that mouseup event happens. Only you never got a mouseup event because it happened over some other random element.