Skip to content

Commit

Permalink
refactor(edges): dont add width and height params
Browse files Browse the repository at this point in the history
  • Loading branch information
moklick committed Jul 24, 2019
1 parent e496cbe commit dbb178b
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 10 deletions.
2 changes: 1 addition & 1 deletion dist/ReactGraph.css
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
width: 100%;
height: 100%;
position: absolute;
z-index: 2;
z-index: 3;
pointer-events: none;
transform-origin: 0 0;
}
Expand Down
5 changes: 5 additions & 0 deletions dist/ReactGraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,10 @@
return element.data && element.data.source && element.data.target;
};
var parseElements = function parseElements(e) {
if (isEdge(e)) {
return e;
}

return _objectSpread2({}, e, {
__rg: {
position: e.position,
Expand Down Expand Up @@ -32893,6 +32897,7 @@
className: nodeClasses,
ref: nodeElement,
style: {
zIndex: selected ? 10 : 3,
transform: "translate(".concat(position.x, "px,").concat(position.y, "px)")
},
onClick: function onClick(e) {
Expand Down
1 change: 1 addition & 0 deletions example/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" type="text/css" href="../dist/ReactGraph.css">
<title>Document</title>
<style>
html, body {
Expand Down
2 changes: 1 addition & 1 deletion src/NodeRenderer/NodeTypes/wrapNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export default NodeComponent => (props) => {
<div
className={nodeClasses}
ref={nodeElement}
style={{ transform: `translate(${position.x}px,${position.y}px)` }}
style={{ zIndex: selected ? 10 : 3, transform: `translate(${position.x}px,${position.y}px)` }}
onClick={(e) => {
if (isInputTarget(e)) {
return false;
Expand Down
20 changes: 13 additions & 7 deletions src/graph-utils.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
export const isEdge = element => element.data && element.data.source && element.data.target;

export const parseElements = e => ({
...e,
__rg: {
position: e.position,
width: null,
height: null
export const parseElements = e => {
if (isEdge(e)) {
return e;
}
});

return {
...e,
__rg: {
position: e.position,
width: null,
height: null
}
}
};

export const separateElements = (res, element) => {
res.edges = res.edges ? res.edges : [];
Expand Down
2 changes: 1 addition & 1 deletion src/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
width: 100%;
height: 100%;
position: absolute;
z-index: 2;
z-index: 3;
pointer-events: none;
transform-origin: 0 0;
}
Expand Down

0 comments on commit dbb178b

Please sign in to comment.