Skip to content

Commit

Permalink
feat(view): add transition in Summary
Browse files Browse the repository at this point in the history
  • Loading branch information
vgihan committed Sep 12, 2022
1 parent 49a5c94 commit 34aee96
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ const drawClusterGraph = (
.attr("transform", (d, i) => getClusterPosition(d, i, true));
group
.transition()
.duration(500)
.duration(300)
.ease(d3.easeLinear)
.attr("transform", (d, i) => getClusterPosition(d, i));

drawClusterBox(group);
Expand All @@ -81,13 +82,11 @@ const ClusterGraph = ({
const clusterSizes = getClusterSizes(data);
const graphHeight = getGraphHeight(clusterSizes);
const selectedIndex = getSelectedIndex(data, selectedData);
const selectedPrevIndex = useRef(-1);

const clusterGraphElements = data.map((cluster, i) => ({
cluster,
clusterSize: clusterSizes[i],
selected: selectedIndex,
prevSelected: selectedPrevIndex.current,
}));

useEffect(() => {
Expand All @@ -97,19 +96,11 @@ const ClusterGraph = ({
);
};
drawClusterGraph(svgRef, clusterGraphElements, handleClickCluster);
selectedPrevIndex.current = selectedIndex;
return () => {
destroyClusterGraph(svgRef);
};
}, [clusterGraphElements, selectedIndex, setSelectedData]);

useEffect(() => {
return () => {
selectedPrevIndex.current = -1;
destroyClusterGraph(svgRef);
};
}, [data]);

return <svg ref={svgRef} width={SVG_WIDTH} height={graphHeight} />;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ export type ClusterGraphElement = {
cluster: ClusterNode;
clusterSize: number;
selected?: number;
prevSelected?: number;
};

export type SVGElementSelection<T extends BaseType> = Selection<
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ export function getClusterPosition(
i: number,
isPrev = false
) {
const selected = (isPrev ? d.prevSelected : d.selected) || Infinity;
const curSelected = d.selected || Infinity;
const selected = isPrev ? Infinity : curSelected;
const margin = selected >= 0 && selected < i ? DETAIL_HEIGHT : 0;
const x = SVG_MARGIN.left;
const y = SVG_MARGIN.top + i * (CLUSTER_HEIGHT + NODE_GAP) + margin;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@
border-radius: $border--radius;
}

@mixin animate($animation, $duration, $method, $times) {
animation: $animation $duration $method $times;
}

@mixin keyframes($name) {
@keyframes #{$name} {
@content;
}
}

.summary__entire {
width: 85%;
margin-left: 20px;
Expand Down Expand Up @@ -158,9 +168,19 @@
.summary_detail_container {
height: 280px;
margin-top: 20px;
overflow: auto;
overflow: scroll;

&::-webkit-scrollbar {
display: none; /* Chrome, Safari, Opera*/
}

@include keyframes(open_detail) {
0% {
height: 0;
}
100% {
height: 280px;
}
}
@include animate(open_detail, 0.3s, linear, 1);
}

0 comments on commit 34aee96

Please sign in to comment.