chore(step-edge): rename bendPosition to stepPosition
This commit is contained in:
@@ -151,15 +151,15 @@ const edges: Edge[] = [
|
||||
source: '7',
|
||||
target: '8',
|
||||
},
|
||||
|
||||
|
||||
// Bend Position Examples
|
||||
{
|
||||
id: 'e9-10',
|
||||
source: '9',
|
||||
target: '10',
|
||||
label: 'bendPosition: 0.2',
|
||||
label: 'stepPosition: 0.2',
|
||||
pathOptions: {
|
||||
bendPosition: 0.2,
|
||||
stepPosition: 0.2,
|
||||
},
|
||||
interactionWidth: 0,
|
||||
},
|
||||
@@ -167,9 +167,9 @@ const edges: Edge[] = [
|
||||
id: 'e11-12',
|
||||
source: '11',
|
||||
target: '12',
|
||||
label: 'bendPosition: 0.5 (default)',
|
||||
label: 'stepPosition: 0.5 (default)',
|
||||
pathOptions: {
|
||||
bendPosition: 0.5,
|
||||
stepPosition: 0.5,
|
||||
},
|
||||
interactionWidth: 0,
|
||||
},
|
||||
@@ -177,9 +177,9 @@ const edges: Edge[] = [
|
||||
id: 'e13-14',
|
||||
source: '13',
|
||||
target: '14',
|
||||
label: 'bendPosition: 0.8',
|
||||
label: 'stepPosition: 0.8',
|
||||
pathOptions: {
|
||||
bendPosition: 0.8,
|
||||
stepPosition: 0.8,
|
||||
},
|
||||
interactionWidth: 0,
|
||||
},
|
||||
|
||||
@@ -36,7 +36,7 @@ function createSmoothStepEdge(params: { isInternal: boolean }) {
|
||||
targetPosition,
|
||||
borderRadius: pathOptions?.borderRadius,
|
||||
offset: pathOptions?.offset,
|
||||
bendPosition: pathOptions?.bendPosition,
|
||||
stepPosition: pathOptions?.stepPosition,
|
||||
});
|
||||
|
||||
const _id = params.isInternal ? undefined : id;
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
targetPosition,
|
||||
borderRadius: pathOptions?.borderRadius,
|
||||
offset: pathOptions?.offset,
|
||||
bendPosition: pathOptions?.bendPosition,
|
||||
stepPosition: pathOptions?.stepPosition
|
||||
})
|
||||
);
|
||||
</script>
|
||||
|
||||
@@ -45,7 +45,7 @@ export type EdgeBase<
|
||||
export type SmoothStepPathOptions = {
|
||||
offset?: number;
|
||||
borderRadius?: number;
|
||||
bendPosition?: number;
|
||||
stepPosition?: number;
|
||||
};
|
||||
|
||||
export type StepPathOptions = {
|
||||
|
||||
@@ -31,7 +31,7 @@ export interface GetSmoothStepPathParams {
|
||||
* 0 = at source, 1 = at target, 0.5 = midpoint
|
||||
* @default 0.5
|
||||
*/
|
||||
bendPosition?: number;
|
||||
stepPosition?: number;
|
||||
}
|
||||
|
||||
const handleDirections = {
|
||||
@@ -69,7 +69,7 @@ function getPoints({
|
||||
targetPosition = Position.Top,
|
||||
center,
|
||||
offset,
|
||||
bendPosition,
|
||||
stepPosition,
|
||||
}: {
|
||||
source: XYPosition;
|
||||
sourcePosition: Position;
|
||||
@@ -77,7 +77,7 @@ function getPoints({
|
||||
targetPosition: Position;
|
||||
center: Partial<XYPosition>;
|
||||
offset: number;
|
||||
bendPosition: number;
|
||||
stepPosition: number;
|
||||
}): [XYPosition[], number, number, number, number] {
|
||||
const sourceDir = handleDirections[sourcePosition];
|
||||
const targetDir = handleDirections[targetPosition];
|
||||
@@ -103,9 +103,9 @@ function getPoints({
|
||||
targetY: target.y,
|
||||
});
|
||||
|
||||
// Calculate bend position based on the bendPosition parameter
|
||||
const bendX = sourceGapped.x + (targetGapped.x - sourceGapped.x) * bendPosition;
|
||||
const bendY = sourceGapped.y + (targetGapped.y - sourceGapped.y) * bendPosition;
|
||||
// Calculate bend position based on the stepPosition parameter
|
||||
const bendX = sourceGapped.x + (targetGapped.x - sourceGapped.x) * stepPosition;
|
||||
const bendY = sourceGapped.y + (targetGapped.y - sourceGapped.y) * stepPosition;
|
||||
|
||||
// opposite handle positions, default case
|
||||
if (sourceDir[dirAccessor] * targetDir[dirAccessor] === -1) {
|
||||
@@ -265,8 +265,8 @@ export function getSmoothStepPath({
|
||||
centerX,
|
||||
centerY,
|
||||
offset = 20,
|
||||
bendPosition = 0.5,
|
||||
}: GetSmoothStepPathParams): [path: string, labelX: number, labelY: number, offsetX: number, offsetY: number] {
|
||||
stepPosition = 0.5,
|
||||
}: GetSmoothStepPathParams): [path: string, labelX: number, labelY: number, offsetX: number, offsetY: number] {
|
||||
const [points, labelX, labelY, offsetX, offsetY] = getPoints({
|
||||
source: { x: sourceX, y: sourceY },
|
||||
sourcePosition,
|
||||
@@ -274,7 +274,7 @@ export function getSmoothStepPath({
|
||||
targetPosition,
|
||||
center: { x: centerX, y: centerY },
|
||||
offset,
|
||||
bendPosition,
|
||||
stepPosition,
|
||||
});
|
||||
|
||||
const path = points.reduce<string>((res, p, i) => {
|
||||
|
||||
Reference in New Issue
Block a user