From d7cadc384fce5efebf0cd446fd2949f406170a4a Mon Sep 17 00:00:00 2001 From: JUDIT GRESKOVITS Date: Wed, 15 Feb 2017 15:37:30 +0000 Subject: [PATCH] Fix touches for topology --- ui/src/components/topology/graph-node.js | 8 ++-- ui/src/components/topology/topology-graph.js | 49 +++++++++++++++----- 2 files changed, 40 insertions(+), 17 deletions(-) diff --git a/ui/src/components/topology/graph-node.js b/ui/src/components/topology/graph-node.js index 344a6a00..5ad315e9 100644 --- a/ui/src/components/topology/graph-node.js +++ b/ui/src/components/topology/graph-node.js @@ -86,11 +86,7 @@ const GraphNode = ({ }; return ( - + { if(dragInfo.dragging) { - const offset = { - x: evt.clientX - dragInfo.position.x, - y: evt.clientY - dragInfo.position.y - }; + let offset = {}; + if(evt.changedTouches) { + offset = { + x: evt.changedTouches[0].pageX - dragInfo.position.x, + y: evt.changedTouches[0].pageY - dragInfo.position.y + }; + } + else { + offset = { + x: evt.clientX - dragInfo.position.x, + y: evt.clientY - dragInfo.position.y + }; + } const dragNodes = simulationNodes.map((simNode, index) => { if(simNode.id === dragInfo.nodeId) { @@ -180,10 +197,18 @@ class TopologyGraph extends React.Component { nodes: dragNodes }); - dragInfo.position = { - x: evt.clientX, - y: evt.clientY - }; + if(evt.changedTouches) { + dragInfo.position = { + x: evt.changedTouches[0].pageX, + y: evt.changedTouches[0].pageY + }; + } + else { + dragInfo.position = { + x: evt.clientX, + y: evt.clientY + }; + } } };