Highlight targeted node
This commit is contained in:
parent
1a2bc3a98f
commit
1c5f7e017e
|
@ -1,3 +1,4 @@
|
|||
/* global document */
|
||||
|
||||
const r = require('r-dom');
|
||||
|
||||
|
@ -22,6 +23,28 @@ class GraphView extends GraphViewBase {
|
|||
});
|
||||
}
|
||||
|
||||
shouldComponentUpdate(nextProps, nextState) {
|
||||
return super.shouldComponentUpdate(nextProps, nextState) ||
|
||||
this.state.edgeEndNode !== nextState.edgeEndNode;
|
||||
}
|
||||
|
||||
componentDidUpdate(prevProps, prevState) {
|
||||
const { nodeKey } = this.props;
|
||||
|
||||
if (this.state.edgeEndNode !== prevState.edgeEndNode) {
|
||||
if (prevState.edgeEndNode) {
|
||||
const prevNode = document.getElementById('node-' + prevState.edgeEndNode[nodeKey]);
|
||||
prevNode.classList.remove('targeted');
|
||||
}
|
||||
if (this.state.edgeEndNode) {
|
||||
const node = document.getElementById('node-' + this.state.edgeEndNode[nodeKey]);
|
||||
node.classList.add('targeted');
|
||||
}
|
||||
}
|
||||
|
||||
super.componentDidUpdate(prevProps, prevState);
|
||||
}
|
||||
|
||||
handleNodeMove(position, nodeId, shiftKey) {
|
||||
this._super_handleNodeMove(position, nodeId, shiftKey);
|
||||
if (this.props.onNodeMove) {
|
||||
|
|
|
@ -17,8 +17,6 @@ const r = require('r-dom');
|
|||
const { connect } = require('react-redux');
|
||||
const { bindActionCreators } = require('redux');
|
||||
|
||||
const math = require('mathjs');
|
||||
|
||||
const d = require('../../utils/d');
|
||||
|
||||
const {
|
||||
|
|
Loading…
Reference in New Issue
Block a user