Skip to content
This repository has been archived by the owner on Aug 9, 2024. It is now read-only.

Commit

Permalink
fix: comments
Browse files Browse the repository at this point in the history
  • Loading branch information
haxxmaxx committed Feb 11, 2020
1 parent ad0a8f9 commit e217942
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/tree/path.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export function getPoints(d, topId, { depthSpacing, isVertical, x, y }) {
const end = { x: x(d.parent) + halfCard.x, y: y(d.parent) + cardHeight + buttonMargin + buttonHeight };

if (haveNoChildren(d.parent.children)) {
// to leafs
points.push(isVertical
? [
{ x: start.x, y: start.y + halfCard.y },
Expand All @@ -29,11 +30,13 @@ export function getPoints(d, topId, { depthSpacing, isVertical, x, y }) {
{ x: end.x, y: end.y },
]);
} else if (start.x === x(d.parent) || start.y === y(d.parent)) {
// straight line
points.push([
{ x: start.x + halfCard.x, y: start.y },
{ x: end.x, y: end.y },
]);
} else {
// to nodes with children
points.push(isVertical
? [
{ x: start.x + halfCard.x, y: start.y },
Expand All @@ -49,13 +52,15 @@ export function getPoints(d, topId, { depthSpacing, isVertical, x, y }) {
]);
}
} else if (d.parent) {
// to up button
points.push([
{ x: start.x + halfCard.x, y: start.y },
{ x: start.x + halfCard.x, y: start.y - buttonMargin },
]);
}

if (d.children) {
// to expand button
points.push([
{ x: start.x + halfCard.x, y: start.y + cardHeight },
{ x: start.x + halfCard.x, y: start.y + cardHeight + buttonMargin },
Expand Down Expand Up @@ -94,7 +99,6 @@ export function getPath(points) {
}

export default function createPaths(node, positioning, topId) {
// Create the lines (links) between the nodes
node
.append('path')
.attr('class', 'link')
Expand Down
1 change: 1 addition & 0 deletions src/tree/path.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ describe('path', () => {
});

describe('getPoints', () => {
// TODO: update tests when all directions work
const { heightMargin, cardHeight } = constants;
let isVertical;
let nodeSize;
Expand Down

0 comments on commit e217942

Please sign in to comment.