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

@ -8,7 +8,6 @@ import {
Coordinates,
} from 'contexts/GraphContext'
import { roundCorners } from 'svg-round-corners'
import { headerHeight } from 'components/shared/TypebotHeader'
export const computeDropOffPath = (
sourcePosition: Coordinates,
@ -274,20 +273,18 @@ export const computeEdgePathToMouse = ({
}
export const getEndpointTopOffset = (
graphPosition: Coordinates,
endpoints: IdMap<Endpoint>,
endpointId?: string,
isAnalytics?: boolean
graphOffsetY: number,
endpointId?: string
): number | undefined => {
if (!endpointId) return
const endpointRef = endpoints[endpointId]?.ref
if (!endpointRef) return
if (!endpointRef?.current) return
const endpointHeight = 18
return (
8 +
(endpointRef.current?.getBoundingClientRect().top ?? 0) -
graphPosition.y -
headerHeight -
(isAnalytics ? 60 : 0)
endpointRef.current.getBoundingClientRect().top +
endpointHeight / 2 -
graphOffsetY
)
}