Skip to content
This repository has been archived by the owner on Jan 17, 2023. It is now read-only.

Commit

Permalink
Fix pen position tracking
Browse files Browse the repository at this point in the history
  • Loading branch information
Niharika Khanna committed Jan 18, 2018
1 parent 4d22580 commit b0ea374
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions server/src/pages/shot/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -463,19 +463,18 @@ exports.Editor = class Editor extends React.Component {
this.drawContext = this.highlightContext;
this.highlightContext.lineWidth = 20;
this.highlightContext.strokeStyle = this.state.color;
this.canvasContainer.addEventListener("mousemove", this.draw);
this.canvasContainer.addEventListener("mousedown", this.setPosition);
document.addEventListener("mousemove", this.draw);
document.addEventListener("mousedown", this.setPosition);
} else if (this.state.tool == 'pen') {
this.drawContext = this.imageContext;
this.imageContext.globalCompositeOperation = 'source-over';
this.imageContext.strokeStyle = this.state.color;
this.imageContext.lineWidth = this.state.size;
this.canvasContainer.addEventListener("mousemove", this.draw);
this.canvasContainer.addEventListener("mousedown", this.setPosition);
document.addEventListener("mousemove", this.draw);
document.addEventListener("mousedown", this.setPosition);
} else if (this.state.tool == 'crop') {
this.canvasContainer.removeEventListener("mousemove", this.draw);
this.canvasContainer.removeEventListener("mousedown", this.setPosition);
this.canvasContainer.removeEventListener("mouseenter", this.setPosition);
document.removeEventListener("mousemove", this.draw);
document.removeEventListener("mousedown", this.setPosition);
document.addEventListener("mousemove", this.mousemove);
document.addEventListener("mousedown", this.mousedown);
document.addEventListener("mouseup", this.mouseup);
Expand Down Expand Up @@ -543,7 +542,7 @@ class ColorPicker extends React.Component {
}

onClickSwatch(e) {
let color = e.target.style.backgroundColor
let color = e.target.style.backgroundColor;
this.setState({color, pickerActive: false});
this.props.setColor(color);
}
Expand Down

0 comments on commit b0ea374

Please sign in to comment.