mirror of
https://github.com/scratchfoundation/scratch-paint.git
synced 2024-12-23 05:52:42 -05:00
lint and clean up some things
This commit is contained in:
parent
6732483d80
commit
dbe24ed50c
2 changed files with 15 additions and 12 deletions
|
@ -7,7 +7,7 @@ import Modes from '../modes/modes';
|
||||||
import {changeMode} from '../reducers/modes';
|
import {changeMode} from '../reducers/modes';
|
||||||
import {clearSelectedItems, setSelectedItems} from '../reducers/selected-items';
|
import {clearSelectedItems, setSelectedItems} from '../reducers/selected-items';
|
||||||
|
|
||||||
import {getSelectedLeafItems} from '../helper/selection';
|
import {clearSelection, getSelectedLeafItems} from '../helper/selection';
|
||||||
import RectTool from '../helper/tools/rect-tool';
|
import RectTool from '../helper/tools/rect-tool';
|
||||||
import RectModeComponent from '../components/rect-mode/rect-mode.jsx';
|
import RectModeComponent from '../components/rect-mode/rect-mode.jsx';
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ class RectMode extends React.Component {
|
||||||
return nextProps.isRectModeActive !== this.props.isRectModeActive;
|
return nextProps.isRectModeActive !== this.props.isRectModeActive;
|
||||||
}
|
}
|
||||||
activateTool () {
|
activateTool () {
|
||||||
this.props.clearSelectedItems();
|
clearSelection(this.props.clearSelectedItems);
|
||||||
this.tool = new RectTool(
|
this.tool = new RectTool(
|
||||||
this.props.setSelectedItems,
|
this.props.setSelectedItems,
|
||||||
this.props.clearSelectedItems,
|
this.props.clearSelectedItems,
|
||||||
|
|
|
@ -51,13 +51,10 @@ class RectTool extends paper.Tool {
|
||||||
this.colorState = colorState;
|
this.colorState = colorState;
|
||||||
}
|
}
|
||||||
handleMouseDown (event) {
|
handleMouseDown (event) {
|
||||||
const clickedItem = paper.project.hitTest(event.point, this.getHitOptions());
|
if (this.boundingBoxTool.onMouseDown(event, false /* clone */, false /* multiselect */, this.getHitOptions())) {
|
||||||
if (clickedItem) {
|
|
||||||
this.isBoundingBoxMode = true;
|
this.isBoundingBoxMode = true;
|
||||||
this.boundingBoxTool.onMouseDown(event, false /* clone */, false /* multiselect */, this.getHitOptions());
|
|
||||||
} else {
|
} else {
|
||||||
this.isBoundingBoxMode = false;
|
this.isBoundingBoxMode = false;
|
||||||
this.boundingBoxTool.removeBoundsPath();
|
|
||||||
clearSelection(this.clearSelectedItems);
|
clearSelection(this.clearSelectedItems);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -95,12 +92,18 @@ class RectTool extends paper.Tool {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.rect) {
|
if (this.rect) {
|
||||||
|
if (this.rect.area < RectTool.TOLERANCE / paper.view.zoom) {
|
||||||
|
// Tiny rectangle created unintentionally?
|
||||||
|
this.rect.remove();
|
||||||
|
this.rect = null;
|
||||||
|
} else {
|
||||||
this.rect.selected = true;
|
this.rect.selected = true;
|
||||||
this.boundingBoxTool.setSelectionBounds();
|
this.boundingBoxTool.setSelectionBounds();
|
||||||
this.onUpdateSvg();
|
this.onUpdateSvg();
|
||||||
this.rect = null;
|
this.rect = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
deactivateTool () {
|
deactivateTool () {
|
||||||
this.boundingBoxTool.removeBoundsPath();
|
this.boundingBoxTool.removeBoundsPath();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue