How to tell if mouse moved during .click()?

前端 未结 4 1326
半阙折子戏
半阙折子戏 2021-01-23 22:53

According to the jQuery documentation for .click(), the event is triggered only after this series of events:

  • The mouse button is depressed while the pointer is ins
4条回答
  •  庸人自扰
    2021-01-23 23:55

    No, there is no such event, as that would be almost completely useless. It's very common that the mouse moves slightly while clicking even if the user didn't intend that, especially with a regular mouse where the button for clicking is located on the moused itself.

    Get the mouse coordinates in the mousedown and mouseup events, and act on the mouseup event depending on how far the mouse has moved.

提交回复
热议问题