2
0

perf(editor): ️ Improve graph transition perf

This commit is contained in:
Baptiste Arnaud
2022-02-14 18:56:29 +01:00
parent e7d1f5d674
commit 714f7c8ce5
9 changed files with 61 additions and 42 deletions

View File

@ -20,9 +20,8 @@ export const Edge = ({ edge }: { edge: EdgeProps }) => {
previewingEdge,
sourceEndpoints,
targetEndpoints,
graphPosition,
blocksCoordinates,
isReadOnly,
graphOffsetY,
} = useGraph()
const isPreviewing = previewingEdge?.id === edge.id
@ -34,25 +33,27 @@ export const Edge = ({ edge }: { edge: EdgeProps }) => {
const sourceTop = useMemo(
() =>
getEndpointTopOffset(
graphPosition,
sourceEndpoints,
getSourceEndpointId(edge),
isReadOnly
graphOffsetY,
getSourceEndpointId(edge)
),
// eslint-disable-next-line react-hooks/exhaustive-deps
[edge, graphPosition, sourceEndpoints, sourceBlockCoordinates?.y]
[
sourceBlockCoordinates?.x,
sourceBlockCoordinates?.y,
edge,
sourceEndpoints,
]
)
const targetTop = useMemo(
() =>
getEndpointTopOffset(
graphPosition,
targetEndpoints,
edge?.to.stepId,
isReadOnly
),
() => getEndpointTopOffset(targetEndpoints, graphOffsetY, edge?.to.stepId),
// eslint-disable-next-line react-hooks/exhaustive-deps
[graphPosition, targetEndpoints, edge?.to.stepId, targetBlockCoordinates?.y]
[
targetBlockCoordinates?.x,
targetBlockCoordinates?.y,
edge?.to.stepId,
targetEndpoints,
]
)
const path = useMemo(() => {