Remove scroll action on eraser and brush

This commit is contained in:
Paul Kaplan 2017-10-27 10:16:13 -04:00
parent 770a138e21
commit d4b28a8817
2 changed files with 2 additions and 27 deletions

View file

@ -17,8 +17,7 @@ class BrushMode extends React.Component {
super(props);
bindAll(this, [
'activateTool',
'deactivateTool',
'onScroll'
'deactivateTool'
]);
this.blob = new Blobbiness(
this.props.onUpdateSvg, this.props.clearSelectedItems);
@ -48,9 +47,6 @@ class BrushMode extends React.Component {
// TODO: Instead of clearing selection, consider a kind of "draw inside"
// analogous to how selection works with eraser
clearSelection(this.props.clearSelectedItems);
// TODO: This is temporary until a component that provides the brush size is hooked up
this.props.canvas.addEventListener('mousewheel', this.onScroll);
this.blob.activateTool({
isEraser: false,
...this.props.colorState,
@ -58,17 +54,8 @@ class BrushMode extends React.Component {
});
}
deactivateTool () {
this.props.canvas.removeEventListener('mousewheel', this.onScroll);
this.blob.deactivateTool();
}
onScroll (event) {
if (event.deltaY < 0) {
this.props.changeBrushSize(this.props.brushModeState.brushSize + 1);
} else if (event.deltaY > 0 && this.props.brushModeState.brushSize > 1) {
this.props.changeBrushSize(this.props.brushModeState.brushSize - 1);
}
return true;
}
render () {
return (
<BrushModeComponent

View file

@ -14,8 +14,7 @@ class EraserMode extends React.Component {
super(props);
bindAll(this, [
'activateTool',
'deactivateTool',
'onScroll'
'deactivateTool'
]);
this.blob = new Blobbiness(
this.props.onUpdateSvg, this.props.clearSelectedItems);
@ -41,22 +40,11 @@ class EraserMode extends React.Component {
return nextProps.isEraserModeActive !== this.props.isEraserModeActive;
}
activateTool () {
this.props.canvas.addEventListener('mousewheel', this.onScroll);
this.blob.activateTool({isEraser: true, ...this.props.eraserModeState});
}
deactivateTool () {
this.props.canvas.removeEventListener('mousewheel', this.onScroll);
this.blob.deactivateTool();
}
onScroll (event) {
event.preventDefault();
if (event.deltaY < 0) {
this.props.changeBrushSize(this.props.eraserModeState.brushSize + 1);
} else if (event.deltaY > 0 && this.props.eraserModeState.brushSize > 1) {
this.props.changeBrushSize(this.props.eraserModeState.brushSize - 1);
}
}
render () {
return (
<EraserModeComponent