detect move of mouse while clicked and detect doubleclick

for the moment I have implemented different actions for when a person clicks on a canvas and when a person clicks and drags something. I did this by binding the mousedown event to my canvas and in that function there is made the difference between a drag or a mouseup. This works very good, but I have a problem when I also want to support doubleclicking on elements. The normal way to implement this is like this: $(canvas).click(function1); $(canvas).dblclick(function2); but I didn't implemented that way because I had to check whether or not the mouse moved (i.e. dragged). This is my current implementation: var handler = { clicked:function(e){ ... $(canvas).bind('mousemove', handler.dragged); $(window).bind('mouseup', handler.dropped); }, dragged:function(e){ ... }, dropped:function(e){ function loop(ctr){ if (ctr

以上就是detect move of mouse while clicked and detect doubleclick的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准