From c423fcda39e816fc81ad0ba66778832a97ebe9c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Tue, 3 Dec 2013 22:25:04 +0100 Subject: [PATCH] Only handle and fire mousemove events when the user's either dragging or moving the mouse within the view. Fixes #352. --- src/ui/View.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/ui/View.js b/src/ui/View.js index 070ca063..eb5a3e46 100644 --- a/src/ui/View.js +++ b/src/ui/View.js @@ -666,15 +666,18 @@ var View = Base.extend(Callback, /** @lends View# */{ if (!(view = view || View._focused)) return; var point = event && viewToProject(view, event); - if (view._onMouseMove) - view._onMouseMove(event, point); - if (tool = view._scope._tool) { - // If there's no onMouseDrag, fire onMouseMove while dragging too. - if (tool._onHandleEvent(dragging && tool.responds('mousedrag') - ? 'mousedrag' : 'mousemove', point, event)) - DomEvent.stop(event); + if (dragging || new Rectangle(new Point(), + view.getViewSize()).contains(point)) { + if (view._onMouseMove) + view._onMouseMove(event, point); + if (tool = view._scope._tool) { + // If there's no onMouseDrag, fire onMouseMove while dragging. + if (tool._onHandleEvent(dragging && tool.responds('mousedrag') + ? 'mousedrag' : 'mousemove', point, event)) + DomEvent.stop(event); + } + view.draw(true); } - view.draw(true); } function mouseup(event) {