mirror of
https://github.com/scratchfoundation/scratch-paint.git
synced 2024-12-22 21:42:30 -05:00
remove references to hover
This commit is contained in:
parent
131193ef73
commit
b62c2e32cb
2 changed files with 3 additions and 35 deletions
|
@ -5,7 +5,6 @@ import bindAll from 'lodash.bindall';
|
|||
import Modes from '../modes/modes';
|
||||
|
||||
import {changeMode} from '../reducers/modes';
|
||||
import {clearHoveredItem, setHoveredItem} from '../reducers/hover';
|
||||
import {clearSelectedItems} from '../reducers/selected-items';
|
||||
|
||||
import {clearSelection} from '../helper/selection';
|
||||
|
@ -26,9 +25,6 @@ class PenMode extends React.Component {
|
|||
}
|
||||
}
|
||||
componentWillReceiveProps (nextProps) {
|
||||
if (this.tool && nextProps.hoveredItemId !== this.props.hoveredItemId) {
|
||||
this.tool.setPrevHoveredItemId(nextProps.hoveredItemId);
|
||||
}
|
||||
if (this.tool &&
|
||||
(nextProps.colorState.strokeColor !== this.props.colorState.strokeColor ||
|
||||
nextProps.colorState.strokeWidth !== this.props.colorState.strokeWidth)) {
|
||||
|
@ -47,12 +43,9 @@ class PenMode extends React.Component {
|
|||
activateTool () {
|
||||
clearSelection(this.props.clearSelectedItems);
|
||||
this.tool = new PenTool(
|
||||
this.props.setHoveredItem,
|
||||
this.props.clearHoveredItem,
|
||||
this.props.clearSelectedItems,
|
||||
this.props.onUpdateSvg
|
||||
);
|
||||
this.tool.setPrevHoveredItemId(this.props.hoveredItemId);
|
||||
this.tool.setColorState(this.props.colorState);
|
||||
this.tool.activate();
|
||||
}
|
||||
|
@ -69,7 +62,6 @@ class PenMode extends React.Component {
|
|||
}
|
||||
|
||||
PenMode.propTypes = {
|
||||
clearHoveredItem: PropTypes.func.isRequired,
|
||||
clearSelectedItems: PropTypes.func.isRequired,
|
||||
colorState: PropTypes.shape({
|
||||
fillColor: PropTypes.string,
|
||||
|
@ -77,25 +69,16 @@ PenMode.propTypes = {
|
|||
strokeWidth: PropTypes.number
|
||||
}).isRequired,
|
||||
handleMouseDown: PropTypes.func.isRequired,
|
||||
hoveredItemId: PropTypes.number,
|
||||
isPenModeActive: PropTypes.bool.isRequired,
|
||||
onUpdateSvg: PropTypes.func.isRequired,
|
||||
setHoveredItem: PropTypes.func.isRequired
|
||||
onUpdateSvg: PropTypes.func.isRequired
|
||||
};
|
||||
|
||||
const mapStateToProps = state => ({
|
||||
colorState: state.scratchPaint.color,
|
||||
isPenModeActive: state.scratchPaint.mode === Modes.PEN,
|
||||
hoveredItemId: state.scratchPaint.hoveredItemId
|
||||
isPenModeActive: state.scratchPaint.mode === Modes.PEN
|
||||
|
||||
});
|
||||
const mapDispatchToProps = dispatch => ({
|
||||
setHoveredItem: hoveredItemId => {
|
||||
dispatch(setHoveredItem(hoveredItemId));
|
||||
},
|
||||
clearHoveredItem: () => {
|
||||
dispatch(clearHoveredItem());
|
||||
},
|
||||
clearSelectedItems: () => {
|
||||
dispatch(clearSelectedItems());
|
||||
},
|
||||
|
|
|
@ -15,19 +15,14 @@ class PenTool extends paper.Tool {
|
|||
return 2;
|
||||
}
|
||||
/**
|
||||
* @param {function} setHoveredItem Callback to set the hovered item
|
||||
* @param {function} clearHoveredItem Callback to clear the hovered item
|
||||
* @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
|
||||
*/
|
||||
constructor (setHoveredItem, clearHoveredItem, clearSelectedItems, onUpdateSvg) {
|
||||
constructor (clearSelectedItems, onUpdateSvg) {
|
||||
super();
|
||||
this.setHoveredItem = setHoveredItem;
|
||||
this.clearHoveredItem = clearHoveredItem;
|
||||
this.clearSelectedItems = clearSelectedItems;
|
||||
this.onUpdateSvg = onUpdateSvg;
|
||||
|
||||
this.prevHoveredItemId = null;
|
||||
this.colorState = null;
|
||||
this.path = null;
|
||||
this.hitResult = null;
|
||||
|
@ -45,16 +40,6 @@ class PenTool extends paper.Tool {
|
|||
|
||||
this.fixedDistance = 2;
|
||||
}
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
setColorState (colorState) {
|
||||
this.colorState = colorState;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue