首页 > 如何监听鼠标按住和拖动的事件?

如何监听鼠标按住和拖动的事件?

我有一个想法,就是监听mousedown,在事件处理中setInterval循环处理,mouseup的时候clearInterval。

请问大家怎么处理这样的事件,以及触摸屏下使用什么方法代替?


监听mousedown, mousemove,mouseup,dragstart,dragend, mouseenter足矣 何以要在interval中处理?在鼠标移动过程中 需要不断处理吗? 触屏用touchevent


按住鼠标状态是的当mousedown事件触发后到mouseup事件触发前. 见下面这个例子. 当按住绿色按钮时,hold事件触发。 hold state


如果循环打印的话,这样确实行.

触摸屏用touchstart替换mousedown,用touchend替换mousedown(后者是理论上),由于兼容问题,touchend有时候不触发,而且触摸很敏感,基本上touchstart的时候会触发touchmove,所以直接用touchmove事件打印吧

【热门文章】
【热门文章】