From 34f01d7e9fe08f30214cb58ba08471748d68e908 Mon Sep 17 00:00:00 2001 From: Oliver Ross Date: Thu, 25 Oct 2018 09:22:55 +0100 Subject: [PATCH 1/4] [#376] when dragging a node, make sure any existing drag transaction is ended and state reset --- the-graph/the-graph-node.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/the-graph/the-graph-node.js b/the-graph/the-graph-node.js index 680cad78..8d7b0565 100644 --- a/the-graph/the-graph-node.js +++ b/the-graph/the-graph-node.js @@ -99,7 +99,7 @@ module.exports.register = function (context) { }, componentDidMount: function () { var domNode = ReactDOM.findDOMNode(this); - + // Dragging domNode.addEventListener("panstart", this.onTrackStart); @@ -141,10 +141,13 @@ module.exports.register = function (context) { if (this.props.export) { this.props.graph.startTransaction('moveexport'); } else { + if (this.state.moving === true) { + this.setState({ moving: false }); + this.setState({ lastTrackX: null, lastTrackY: null }); + this.props.graph.endTransaction("movenode"); + } this.props.graph.startTransaction('movenode'); } - this.setState({ moving: true }); - this.setState({ lastTrackX: 0, lastTrackY: 0}); }, onTrack: function (event) { // Don't fire on graph @@ -230,7 +233,7 @@ module.exports.register = function (context) { // Get mouse position if (event.gesture) { - event = event.gesture.srcEvent; // unpack hammer.js gesture event + event = event.gesture.srcEvent; // unpack hammer.js gesture event } var x = event.x || event.clientX || 0; var y = event.y || event.clientY || 0; @@ -343,7 +346,7 @@ module.exports.register = function (context) { shouldComponentUpdate: function (nextProps, nextState) { // Only rerender if changed return ( - nextProps.x !== this.props.x || + nextProps.x !== this.props.x || nextProps.y !== this.props.y || nextProps.icon !== this.props.icon || nextProps.label !== this.props.label || @@ -471,7 +474,7 @@ module.exports.register = function (context) { var borderRectOptions = TheGraph.merge(TheGraph.config.node.border, { width: this.props.width, height: this.props.height }); var borderRect = TheGraph.factories.node.createNodeBorderRect.call(this, borderRectOptions); - + var innerRectOptions = TheGraph.merge(TheGraph.config.node.innerRect, { width: this.props.width - 6, height: this.props.height - 6 }); var innerRect = TheGraph.factories.node.createNodeInnerRect.call(this, innerRectOptions); From 736714a7fbfcfcf4679606c55af45193c214cb37 Mon Sep 17 00:00:00 2001 From: Oliver Ross Date: Thu, 25 Oct 2018 09:24:28 +0100 Subject: [PATCH 2/4] set state correctly when dragging node --- the-graph/the-graph-node.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/the-graph/the-graph-node.js b/the-graph/the-graph-node.js index 8d7b0565..734c15a5 100644 --- a/the-graph/the-graph-node.js +++ b/the-graph/the-graph-node.js @@ -148,6 +148,8 @@ module.exports.register = function (context) { } this.props.graph.startTransaction('movenode'); } + this.setState({ moving: true }); + this.setState({ lastTrackX: 0, lastTrackY: 0}); }, onTrack: function (event) { // Don't fire on graph From 92834183f273276b38ae4af5ecf0b0628ca0f1ab Mon Sep 17 00:00:00 2001 From: Oliver Ross Date: Thu, 25 Oct 2018 10:01:16 +0100 Subject: [PATCH 3/4] added .nvmrc so travis uses lts --- .nvmrc | 1 + 1 file changed, 1 insertion(+) create mode 100644 .nvmrc diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 00000000..b009dfb9 --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +lts/* From 5fa9b2fb21925d370da3a7e98ed4d7f10d6e8e8f Mon Sep 17 00:00:00 2001 From: Oliver Ross Date: Thu, 25 Oct 2018 10:08:24 +0100 Subject: [PATCH 4/4] removed node version from travis file, so will use the version in .nvmrc --- .travis.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 38036583..c9278668 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,4 @@ language: node_js -node_js: -- node before_script: - npm install -g grunt-cli deploy: