mirror of
https://github.com/scratchfoundation/scratch-paint.git
synced 2025-01-24 05:09:52 -05:00
Remove scroll action on eraser and brush
This commit is contained in:
parent
770a138e21
commit
d4b28a8817
2 changed files with 2 additions and 27 deletions
|
@ -17,8 +17,7 @@ class BrushMode extends React.Component {
|
||||||
super(props);
|
super(props);
|
||||||
bindAll(this, [
|
bindAll(this, [
|
||||||
'activateTool',
|
'activateTool',
|
||||||
'deactivateTool',
|
'deactivateTool'
|
||||||
'onScroll'
|
|
||||||
]);
|
]);
|
||||||
this.blob = new Blobbiness(
|
this.blob = new Blobbiness(
|
||||||
this.props.onUpdateSvg, this.props.clearSelectedItems);
|
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"
|
// TODO: Instead of clearing selection, consider a kind of "draw inside"
|
||||||
// analogous to how selection works with eraser
|
// analogous to how selection works with eraser
|
||||||
clearSelection(this.props.clearSelectedItems);
|
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({
|
this.blob.activateTool({
|
||||||
isEraser: false,
|
isEraser: false,
|
||||||
...this.props.colorState,
|
...this.props.colorState,
|
||||||
|
@ -58,17 +54,8 @@ class BrushMode extends React.Component {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
deactivateTool () {
|
deactivateTool () {
|
||||||
this.props.canvas.removeEventListener('mousewheel', this.onScroll);
|
|
||||||
this.blob.deactivateTool();
|
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 () {
|
render () {
|
||||||
return (
|
return (
|
||||||
<BrushModeComponent
|
<BrushModeComponent
|
||||||
|
|
|
@ -14,8 +14,7 @@ class EraserMode extends React.Component {
|
||||||
super(props);
|
super(props);
|
||||||
bindAll(this, [
|
bindAll(this, [
|
||||||
'activateTool',
|
'activateTool',
|
||||||
'deactivateTool',
|
'deactivateTool'
|
||||||
'onScroll'
|
|
||||||
]);
|
]);
|
||||||
this.blob = new Blobbiness(
|
this.blob = new Blobbiness(
|
||||||
this.props.onUpdateSvg, this.props.clearSelectedItems);
|
this.props.onUpdateSvg, this.props.clearSelectedItems);
|
||||||
|
@ -41,22 +40,11 @@ class EraserMode extends React.Component {
|
||||||
return nextProps.isEraserModeActive !== this.props.isEraserModeActive;
|
return nextProps.isEraserModeActive !== this.props.isEraserModeActive;
|
||||||
}
|
}
|
||||||
activateTool () {
|
activateTool () {
|
||||||
this.props.canvas.addEventListener('mousewheel', this.onScroll);
|
|
||||||
|
|
||||||
this.blob.activateTool({isEraser: true, ...this.props.eraserModeState});
|
this.blob.activateTool({isEraser: true, ...this.props.eraserModeState});
|
||||||
}
|
}
|
||||||
deactivateTool () {
|
deactivateTool () {
|
||||||
this.props.canvas.removeEventListener('mousewheel', this.onScroll);
|
|
||||||
this.blob.deactivateTool();
|
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 () {
|
render () {
|
||||||
return (
|
return (
|
||||||
<EraserModeComponent
|
<EraserModeComponent
|
||||||
|
|
Loading…
Reference in a new issue