Skip to content

Commit

Permalink
no need to check active state when handling or stopping updates
Browse files Browse the repository at this point in the history
  • Loading branch information
WickyNilliams committed Oct 4, 2016
1 parent 102432c commit 85dcf86
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions src/components/DraggableMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,24 +47,20 @@ const DraggableMixin = {
},

handleUpdate(e) {
if (this.state.active) {
e.preventDefault();
const { x, y } = this.getPosition(e);
this.updatePosition(this.rect, x, y);
}
e.preventDefault();
const { x, y } = this.getPosition(e);
this.updatePosition(this.rect, x, y);
},

stopUpdates() {
if(this.state.active) {
const { document } = this;
const { document } = this;

document.removeEventListener("mousemove", this.handleUpdate);
document.removeEventListener("touchmove", this.handleUpdate);
document.removeEventListener("mouseup", this.stopUpdates);
document.removeEventListener("touchend", this.stopUpdates);
document.removeEventListener("mousemove", this.handleUpdate);
document.removeEventListener("touchmove", this.handleUpdate);
document.removeEventListener("mouseup", this.stopUpdates);
document.removeEventListener("touchend", this.stopUpdates);

this.setState({ active : false });
}
this.setState({ active : false });
},

getPosition(e) {
Expand Down

0 comments on commit 85dcf86

Please sign in to comment.