From 7b3341e6f8ad00e13d0b8b3af9d5b19077f8be57 Mon Sep 17 00:00:00 2001 From: 06wj <06wj@163.com> Date: Thu, 20 Jul 2017 11:13:02 +0800 Subject: [PATCH] fix: dragMove event should be sent at the end, fix #92 --- src/util/drag.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/util/drag.js b/src/util/drag.js index dc33031b..20189b44 100644 --- a/src/util/drag.js +++ b/src/util/drag.js @@ -73,7 +73,6 @@ var drag = { updateMouse(e); that.off(Hilo.event.POINTER_START, onStart); - that.fire("dragStart", mouse); that.__dragX = that.x - mouse.x; that.__dragY = that.y - mouse.y; @@ -83,26 +82,27 @@ var drag = { } stage.on(Hilo.event.POINTER_MOVE, onMove); document.addEventListener(Hilo.event.POINTER_END, onStop); + that.fire("dragStart", mouse); } function onStop(e){ document.removeEventListener(Hilo.event.POINTER_END, onStop); stage && stage.off(Hilo.event.POINTER_MOVE, onMove); - that.fire("dragEnd", mouse); that.on(Hilo.event.POINTER_START, onStart); + that.fire("dragEnd", mouse); } function onMove(e){ updateMouse(e); - that.fire("dragMove", mouse); - var x = mouse.x + that.__dragX; var y = mouse.y + that.__dragY; that.x = Math.max(minX, Math.min(maxX, x)); that.y = Math.max(minY, Math.min(maxY, y)); + + that.fire("dragMove", mouse); } function updateMouse(e){