From 5b3ac75e2a17710a3830fb7b34e9385e15fb5438 Mon Sep 17 00:00:00 2001 From: willersilva Date: Thu, 15 Aug 2019 22:13:32 -0300 Subject: [PATCH 1/2] Move node without collisions with another nodes Signed-off-by: willersilva --- the-graph/the-graph-node.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/the-graph/the-graph-node.js b/the-graph/the-graph-node.js index 734c15a5..49a155d0 100644 --- a/the-graph/the-graph-node.js +++ b/the-graph/the-graph-node.js @@ -97,6 +97,21 @@ module.exports.register = function (context) { lastTrackY: null, }; }, + componentDidUpdate(prevProps, prevState){ + if(prevState.moving !== this.state.moving){ + if(this.state.moving) { + document.getElementsByClassName("nodes")[0].childNodes.forEach(item => { + if(item !== ReactDOM.findDOMNode(this)) + item.style.pointerEvents = "none"; + }); + } + else { + document.getElementsByClassName("nodes")[0].childNodes.forEach(item => { + item.style.pointerEvents = "auto"; + }); + } + } + }, componentDidMount: function () { var domNode = ReactDOM.findDOMNode(this); @@ -357,7 +372,8 @@ module.exports.register = function (context) { nextProps.selected !== this.props.selected || nextProps.error !== this.props.error || nextProps.highlightPort !== this.props.highlightPort || - nextProps.ports.dirty === true + nextProps.ports.dirty === true || + nextState.moving !== this.state.moving ); }, render: function() { From 73cf295784bf8087c0ef66c4b3db05ac11a6316e Mon Sep 17 00:00:00 2001 From: willersilva Date: Thu, 15 Aug 2019 22:50:17 -0300 Subject: [PATCH 2/2] Fix code pattern es6 Signed-off-by: willersilva --- the-graph/the-graph-node.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/the-graph/the-graph-node.js b/the-graph/the-graph-node.js index 49a155d0..8534cb91 100644 --- a/the-graph/the-graph-node.js +++ b/the-graph/the-graph-node.js @@ -97,16 +97,16 @@ module.exports.register = function (context) { lastTrackY: null, }; }, - componentDidUpdate(prevProps, prevState){ + componentDidUpdate: function (prevProps, prevState){ if(prevState.moving !== this.state.moving){ if(this.state.moving) { - document.getElementsByClassName("nodes")[0].childNodes.forEach(item => { + document.getElementsByClassName("nodes")[0].childNodes.forEach(function (item) { if(item !== ReactDOM.findDOMNode(this)) item.style.pointerEvents = "none"; }); } else { - document.getElementsByClassName("nodes")[0].childNodes.forEach(item => { + document.getElementsByClassName("nodes")[0].childNodes.forEach(function (item) { item.style.pointerEvents = "auto"; }); }