Skip to content

Commit

Permalink
Use this.isDraggingNode to prevent mouse over node and out to trigger…
Browse files Browse the repository at this point in the history
… every time a node drag goes outside of the node that is being dragged (#242)
  • Loading branch information
danielcaldas authored Oct 1, 2019
1 parent e784722 commit 6f99b90
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/components/graph/Graph.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ export default class Graph extends React.Component {
* @returns {undefined}
*/
_onDragEnd = () => {
this.isDraggingNode = false;

if (this.state.draggedNode) {
this.onNodePositionChange(this.state.draggedNode);
this._tick({ draggedNode: null });
Expand Down Expand Up @@ -237,7 +239,9 @@ export default class Graph extends React.Component {
* @returns {undefined}
*/
_onDragStart = () => {
this.isDraggingNode = true;
this.pauseSimulation();

if (this.state.enableFocusAnimation) {
this.setState({ enableFocusAnimation: false });
}
Expand Down Expand Up @@ -365,6 +369,10 @@ export default class Graph extends React.Component {
* @returns {undefined}
*/
onMouseOverNode = id => {
if (this.isDraggingNode) {
return;
}

this.props.onMouseOverNode && this.props.onMouseOverNode(id);

this.state.config.nodeHighlightBehavior && this._setNodeHighlightedValue(id, true);
Expand All @@ -376,6 +384,10 @@ export default class Graph extends React.Component {
* @returns {undefined}
*/
onMouseOutNode = id => {
if (this.isDraggingNode) {
return;
}

this.props.onMouseOutNode && this.props.onMouseOutNode(id);

this.state.config.nodeHighlightBehavior && this._setNodeHighlightedValue(id, false);
Expand Down Expand Up @@ -478,6 +490,7 @@ export default class Graph extends React.Component {

this.focusAnimationTimeout = null;
this.nodeClickTimer = null;
this.isDraggingNode = false;
this.state = initializeGraphState(this.props, this.state);
}

Expand Down

0 comments on commit 6f99b90

Please sign in to comment.