Remove wheel listeners from brush and eraser

This commit is contained in:
Paul Kaplan 2017-10-27 10:22:52 -04:00
parent d4b28a8817
commit 62526889c9
4 changed files with 2 additions and 12 deletions

View file

@ -225,20 +225,16 @@ class PaintEditorComponent extends React.Component {
onUpdateSvg={this.props.onUpdateSvg}
/>
<BrushMode
canvas={this.state.canvas}
onUpdateSvg={this.props.onUpdateSvg}
/>
<EraserMode
canvas={this.state.canvas}
onUpdateSvg={this.props.onUpdateSvg}
/>
<PenMode
canvas={this.state.canvas}
onUpdateSvg={this.props.onUpdateSvg}
/>
{/* Text mode will go here */}
<LineMode
canvas={this.state.canvas}
onUpdateSvg={this.props.onUpdateSvg}
/>
<OvalMode

View file

@ -70,8 +70,6 @@ BrushMode.propTypes = {
brushModeState: PropTypes.shape({
brushSize: PropTypes.number.isRequired
}),
canvas: PropTypes.instanceOf(Element).isRequired,
changeBrushSize: PropTypes.func.isRequired,
clearSelectedItems: PropTypes.func.isRequired,
colorState: PropTypes.shape({
fillColor: PropTypes.string,

View file

@ -56,8 +56,6 @@ class EraserMode extends React.Component {
}
EraserMode.propTypes = {
canvas: PropTypes.instanceOf(Element).isRequired,
changeBrushSize: PropTypes.func.isRequired,
clearSelectedItems: PropTypes.func.isRequired,
eraserModeState: PropTypes.shape({
brushSize: PropTypes.number.isRequired

View file

@ -47,7 +47,7 @@ class LineMode extends React.Component {
activateTool () {
clearSelection(this.props.clearSelectedItems);
this.tool = new paper.Tool();
this.path = null;
this.hitResult = null;
@ -182,14 +182,13 @@ class LineMode extends React.Component {
removeHitPoint();
this.hitResult = null;
}
if (this.path) {
this.props.onUpdateSvg();
this.path = null;
}
}
deactivateTool () {
this.props.canvas.removeEventListener('mousewheel', this.onScroll);
this.tool.remove();
this.tool = null;
if (this.hitResult) {
@ -211,7 +210,6 @@ class LineMode extends React.Component {
}
LineMode.propTypes = {
canvas: PropTypes.instanceOf(Element).isRequired,
clearSelectedItems: PropTypes.func.isRequired,
colorState: PropTypes.shape({
fillColor: PropTypes.string,