mirror of
https://github.com/scratchfoundation/scratch-paint.git
synced 2025-01-08 21:52:00 -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 {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 RectModeComponent from '../components/rect-mode/rect-mode.jsx';
|
||||
|
||||
|
@ -39,7 +39,7 @@ class RectMode extends React.Component {
|
|||
return nextProps.isRectModeActive !== this.props.isRectModeActive;
|
||||
}
|
||||
activateTool () {
|
||||
this.props.clearSelectedItems();
|
||||
clearSelection(this.props.clearSelectedItems);
|
||||
this.tool = new RectTool(
|
||||
this.props.setSelectedItems,
|
||||
this.props.clearSelectedItems,
|
||||
|
|
|
@ -51,13 +51,10 @@ class RectTool extends paper.Tool {
|
|||
this.colorState = colorState;
|
||||
}
|
||||
handleMouseDown (event) {
|
||||
const clickedItem = paper.project.hitTest(event.point, this.getHitOptions());
|
||||
if (clickedItem) {
|
||||
if (this.boundingBoxTool.onMouseDown(event, false /* clone */, false /* multiselect */, this.getHitOptions())) {
|
||||
this.isBoundingBoxMode = true;
|
||||
this.boundingBoxTool.onMouseDown(event, false /* clone */, false /* multiselect */, this.getHitOptions());
|
||||
} else {
|
||||
this.isBoundingBoxMode = false;
|
||||
this.boundingBoxTool.removeBoundsPath();
|
||||
clearSelection(this.clearSelectedItems);
|
||||
}
|
||||
}
|
||||
|
@ -95,12 +92,18 @@ class RectTool extends paper.Tool {
|
|||
}
|
||||
|
||||
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.boundingBoxTool.setSelectionBounds();
|
||||
this.onUpdateSvg();
|
||||
this.rect = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
deactivateTool () {
|
||||
this.boundingBoxTool.removeBoundsPath();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue