mirror of
https://github.com/scratchfoundation/scratch-paint.git
synced 2024-12-22 21:42:30 -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,18 +51,15 @@ 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);
|
||||
}
|
||||
}
|
||||
handleMouseDrag (event) {
|
||||
if (event.event.button > 0) return; // only first mouse button
|
||||
if (event.event.button > 0) return; // only first mouse button
|
||||
|
||||
if (this.isBoundingBoxMode) {
|
||||
this.boundingBoxTool.onMouseDrag(event);
|
||||
|
@ -86,7 +83,7 @@ class RectTool extends paper.Tool {
|
|||
styleShape(this.rect, this.colorState);
|
||||
}
|
||||
handleMouseUp (event) {
|
||||
if (event.event.button > 0) return; // only first mouse button
|
||||
if (event.event.button > 0) return; // only first mouse button
|
||||
|
||||
if (this.isBoundingBoxMode) {
|
||||
this.boundingBoxTool.onMouseUp(event);
|
||||
|
@ -95,10 +92,16 @@ class RectTool extends paper.Tool {
|
|||
}
|
||||
|
||||
if (this.rect) {
|
||||
this.rect.selected = true;
|
||||
this.boundingBoxTool.setSelectionBounds();
|
||||
this.onUpdateSvg();
|
||||
this.rect = null;
|
||||
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 () {
|
||||
|
|
Loading…
Reference in a new issue