Skip to content

Commit

Permalink
fix: dragMove event should be sent at the end, fix #92
Browse files Browse the repository at this point in the history
  • Loading branch information
06wj committed Jul 20, 2017
1 parent e63fefd commit 7b3341e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/util/drag.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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){
Expand Down

0 comments on commit 7b3341e

Please sign in to comment.