mirror of
https://github.com/scratchfoundation/scratch-paint.git
synced 2024-12-23 05:52:42 -05:00
Remove hover. Why did I leave hover in all of these
This commit is contained in:
parent
4580fcc7d8
commit
f9772e90ed
2 changed files with 2 additions and 33 deletions
|
@ -5,7 +5,6 @@ import bindAll from 'lodash.bindall';
|
||||||
import Modes from '../modes/modes';
|
import Modes from '../modes/modes';
|
||||||
|
|
||||||
import {changeMode} from '../reducers/modes';
|
import {changeMode} from '../reducers/modes';
|
||||||
import {clearHoveredItem, setHoveredItem} from '../reducers/hover';
|
|
||||||
import {clearSelectedItems, setSelectedItems} from '../reducers/selected-items';
|
import {clearSelectedItems, setSelectedItems} from '../reducers/selected-items';
|
||||||
|
|
||||||
import {getSelectedLeafItems} from '../helper/selection';
|
import {getSelectedLeafItems} from '../helper/selection';
|
||||||
|
@ -26,10 +25,6 @@ class RectMode extends React.Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
componentWillReceiveProps (nextProps) {
|
componentWillReceiveProps (nextProps) {
|
||||||
if (this.tool && nextProps.hoveredItemId !== this.props.hoveredItemId) {
|
|
||||||
this.tool.setPrevHoveredItemId(nextProps.hoveredItemId);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (nextProps.isRectModeActive && !this.props.isRectModeActive) {
|
if (nextProps.isRectModeActive && !this.props.isRectModeActive) {
|
||||||
this.activateTool();
|
this.activateTool();
|
||||||
} else if (!nextProps.isRectModeActive && this.props.isRectModeActive) {
|
} else if (!nextProps.isRectModeActive && this.props.isRectModeActive) {
|
||||||
|
@ -41,8 +36,6 @@ class RectMode extends React.Component {
|
||||||
}
|
}
|
||||||
activateTool () {
|
activateTool () {
|
||||||
this.tool = new RectTool(
|
this.tool = new RectTool(
|
||||||
this.props.setHoveredItem,
|
|
||||||
this.props.clearHoveredItem,
|
|
||||||
this.props.setSelectedItems,
|
this.props.setSelectedItems,
|
||||||
this.props.clearSelectedItems,
|
this.props.clearSelectedItems,
|
||||||
this.props.onUpdateSvg
|
this.props.onUpdateSvg
|
||||||
|
@ -65,27 +58,17 @@ class RectMode extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
RectMode.propTypes = {
|
RectMode.propTypes = {
|
||||||
clearHoveredItem: PropTypes.func.isRequired,
|
|
||||||
clearSelectedItems: PropTypes.func.isRequired,
|
clearSelectedItems: PropTypes.func.isRequired,
|
||||||
handleMouseDown: PropTypes.func.isRequired,
|
handleMouseDown: PropTypes.func.isRequired,
|
||||||
hoveredItemId: PropTypes.number,
|
|
||||||
isRectModeActive: PropTypes.bool.isRequired,
|
isRectModeActive: PropTypes.bool.isRequired,
|
||||||
onUpdateSvg: PropTypes.func.isRequired,
|
onUpdateSvg: PropTypes.func.isRequired,
|
||||||
setHoveredItem: PropTypes.func.isRequired,
|
|
||||||
setSelectedItems: PropTypes.func.isRequired
|
setSelectedItems: PropTypes.func.isRequired
|
||||||
};
|
};
|
||||||
|
|
||||||
const mapStateToProps = state => ({
|
const mapStateToProps = state => ({
|
||||||
isRectModeActive: state.scratchPaint.mode === Modes.RECT,
|
isRectModeActive: state.scratchPaint.mode === Modes.RECT
|
||||||
hoveredItemId: state.scratchPaint.hoveredItemId
|
|
||||||
});
|
});
|
||||||
const mapDispatchToProps = dispatch => ({
|
const mapDispatchToProps = dispatch => ({
|
||||||
setHoveredItem: hoveredItemId => {
|
|
||||||
dispatch(setHoveredItem(hoveredItemId));
|
|
||||||
},
|
|
||||||
clearHoveredItem: () => {
|
|
||||||
dispatch(clearHoveredItem());
|
|
||||||
},
|
|
||||||
clearSelectedItems: () => {
|
clearSelectedItems: () => {
|
||||||
dispatch(clearSelectedItems());
|
dispatch(clearSelectedItems());
|
||||||
},
|
},
|
||||||
|
|
|
@ -6,16 +6,12 @@ import log from '../../log/log';
|
||||||
*/
|
*/
|
||||||
class RectTool extends paper.Tool {
|
class RectTool extends paper.Tool {
|
||||||
/**
|
/**
|
||||||
* @param {function} setHoveredItem Callback to set the hovered item
|
|
||||||
* @param {function} clearHoveredItem Callback to clear the hovered item
|
|
||||||
* @param {function} setSelectedItems Callback to set the set of selected items in the Redux state
|
* @param {function} setSelectedItems Callback to set the set of selected items in the Redux state
|
||||||
* @param {function} clearSelectedItems Callback to clear the set of selected items in the Redux state
|
* @param {function} clearSelectedItems Callback to clear the set of selected items in the Redux state
|
||||||
* @param {!function} onUpdateSvg A callback to call when the image visibly changes
|
* @param {!function} onUpdateSvg A callback to call when the image visibly changes
|
||||||
*/
|
*/
|
||||||
constructor (setHoveredItem, clearHoveredItem, setSelectedItems, clearSelectedItems, onUpdateSvg) {
|
constructor (setSelectedItems, clearSelectedItems, onUpdateSvg) {
|
||||||
super();
|
super();
|
||||||
this.setHoveredItem = setHoveredItem;
|
|
||||||
this.clearHoveredItem = clearHoveredItem;
|
|
||||||
this.setSelectedItems = setSelectedItems;
|
this.setSelectedItems = setSelectedItems;
|
||||||
this.clearSelectedItems = clearSelectedItems;
|
this.clearSelectedItems = clearSelectedItems;
|
||||||
this.onUpdateSvg = onUpdateSvg;
|
this.onUpdateSvg = onUpdateSvg;
|
||||||
|
@ -28,16 +24,6 @@ class RectTool extends paper.Tool {
|
||||||
this.onMouseDrag = this.handleMouseDrag;
|
this.onMouseDrag = this.handleMouseDrag;
|
||||||
this.onMouseUp = this.handleMouseUp;
|
this.onMouseUp = this.handleMouseUp;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* To be called when the hovered item changes. When the select tool hovers over a
|
|
||||||
* new item, it compares against this to see if a hover item change event needs to
|
|
||||||
* be fired.
|
|
||||||
* @param {paper.Item} prevHoveredItemId ID of the highlight item that indicates the mouse is
|
|
||||||
* over a given item currently
|
|
||||||
*/
|
|
||||||
setPrevHoveredItemId (prevHoveredItemId) {
|
|
||||||
this.prevHoveredItemId = prevHoveredItemId;
|
|
||||||
}
|
|
||||||
handleMouseDown () {
|
handleMouseDown () {
|
||||||
log.warn('Rectangle tool not yet implemented');
|
log.warn('Rectangle tool not yet implemented');
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue