From c9337a564ba58b0349719995eac8d67009a0eeeb Mon Sep 17 00:00:00 2001 From: yonava Date: Wed, 20 May 2026 15:51:41 -0400 Subject: [PATCH 1/6] removed animate options from move --- packages/graph/src/base/types.ts | 5 ++- packages/graph/src/base/useGraphCRUD.ts | 9 ++--- packages/graph/src/schematics/edge.ts | 33 ++++++++++--------- .../src/abstract-syntax-trees/MainView.vue | 4 +-- .../useTreeGraphPositioner.ts | 8 ++++- packages/shapes/src/animation/autoAnimate.ts | 3 ++ 6 files changed, 39 insertions(+), 23 deletions(-) diff --git a/packages/graph/src/base/types.ts b/packages/graph/src/base/types.ts index 784d7266..997c022e 100644 --- a/packages/graph/src/base/types.ts +++ b/packages/graph/src/base/types.ts @@ -105,8 +105,11 @@ export const MOVE_NODE_OPTIONS_DEFAULTS: MoveNodeOptions = { broadcast: true, }; -export const BULK_MOVE_NODE_OPTIONS_DEFAULTS: MoveNodeOptions = { +export type BulkMoveNodeOptions = BroadcastOption & AnimateOption; + +export const BULK_MOVE_NODE_OPTIONS_DEFAULTS: BulkMoveNodeOptions = { broadcast: true, + animate: false, }; export type EditEdgeLabelOptions = BroadcastOption & HistoryOption; diff --git a/packages/graph/src/base/useGraphCRUD.ts b/packages/graph/src/base/useGraphCRUD.ts index 21ef2db7..48952ad7 100644 --- a/packages/graph/src/base/useGraphCRUD.ts +++ b/packages/graph/src/base/useGraphCRUD.ts @@ -12,6 +12,7 @@ import { getConnectedEdges } from '../helpers'; import { nodeLetterLabelGetter } from '../labels'; import type { GraphSettings } from '../settings'; import type { GEdge, GNode } from '../types'; +import { AnimationKeyframe } from './../../../shapes/src/animation/interpolation/types'; import type { GraphAnimations } from './animations'; import { ADD_EDGE_DEFAULTS, @@ -299,15 +300,15 @@ export const useGraphCRUD = ({ ...options, }; - const finalizeFrame = autoAnimate.captureFrame(() => - draw(getCtx(magicCanvas.canvas)), - ); + const animate = fullOptions.animate + ? autoAnimate.captureFrame(() => draw(getCtx(magicCanvas.canvas))) + : null; for (const { nodeId, coords } of nodeMovements) { moveNode(nodeId, coords, fullOptions); } - finalizeFrame(); + animate?.(); }; const editEdgeLabel = ( diff --git a/packages/graph/src/schematics/edge.ts b/packages/graph/src/schematics/edge.ts index 42f252c3..fcc3edb3 100644 --- a/packages/graph/src/schematics/edge.ts +++ b/packages/graph/src/schematics/edge.ts @@ -22,19 +22,19 @@ export const getEdgeSchematic = ( ): Omit | undefined => { const { displayEdgeLabels, isGraphDirected } = graph.settings.value; - const [from, to] = getConnectedNodes(edge.id, graph); - const edgesAlongPath = getEdgesAlongPath(from.id, to.id, graph); + const [fromNode, toNode] = getConnectedNodes(edge.id, graph); + const edgesAlongPath = getEdgesAlongPath(fromNode.id, toNode.id, graph); const multipleEdgesInPath = edgesAlongPath.length > 1; - const isSelfDirected = to === from; + const isSelfDirected = toNode.id === fromNode.id; - const fromNodeBorderWidth = graph.getTheme('nodeBorderWidth', from); - const toNodeBorderWidth = graph.getTheme('nodeBorderWidth', to); + const fromNodeBorderWidth = graph.getTheme('nodeBorderWidth', fromNode); + const toNodeBorderWidth = graph.getTheme('nodeBorderWidth', toNode); - const fromNodeSize = graph.getTheme('nodeSize', from); - const toNodeSize = graph.getTheme('nodeSize', to); + const fromNodeSize = graph.getTheme('nodeSize', fromNode); + const toNodeSize = graph.getTheme('nodeSize', toNode); - const angle = Math.atan2(to.y - from.y, to.x - from.x); + const angle = Math.atan2(toNode.y - fromNode.y, toNode.x - fromNode.x); const arrowHeadSpacingAwayFromNode = toNodeBorderWidth / 2 + WHITESPACE_BETWEEN_ARROW_TIP_AND_NODE; @@ -43,10 +43,10 @@ export const getEdgeSchematic = ( y: (toNodeSize + arrowHeadSpacingAwayFromNode) * Math.sin(angle), }; - const edgeStart = { x: from.x, y: from.y }; + const edgeStart = { x: fromNode.x, y: fromNode.y }; const edgeEnd = { - x: to.x - (isGraphDirected ? arrowDrawOffset.x : 0), - y: to.y - (isGraphDirected ? arrowDrawOffset.y : 0), + x: toNode.x - (isGraphDirected ? arrowDrawOffset.x : 0), + y: toNode.y - (isGraphDirected ? arrowDrawOffset.y : 0), }; const edgeWidth = graph.getTheme('edgeWidth', edge); @@ -74,10 +74,13 @@ export const getEdgeSchematic = ( * from causing angle issues when no other edges are present */ graph.edges.value - .filter((e) => (e.from === from.id || e.to === to.id) && e.from !== e.to) + .filter( + (e) => + (e.from === fromNode.id || e.to === toNode.id) && e.from !== e.to, + ) .map((e) => { const [fromNode, toNode] = getConnectedNodes(e.id, graph); - return from.id === fromNode.id ? toNode : fromNode; + return fromNode.id === fromNode.id ? toNode : fromNode; }) .filter( (point, index, self) => @@ -117,7 +120,7 @@ export const getEdgeSchematic = ( const shape = graph.shapes.uturn({ id: edge.id, spacing: edgeWidth * 1.2, - at: { x: from.x, y: from.y }, + at: { x: fromNode.x, y: fromNode.y }, upDistance, downDistance, rotation: largestAngularSpace, @@ -136,7 +139,7 @@ export const getEdgeSchematic = ( const sumOfToAndFromNodeSize = fromNodeSize + fromNodeBorderWidth / 2 + toNodeSize + toNodeBorderWidth / 2; const distanceSquaredBetweenNodes = - (from.x - to.x) ** 2 + (from.y - to.y) ** 2; + (fromNode.x - toNode.x) ** 2 + (fromNode.y - toNode.y) ** 2; const areNodesTouching = sumOfToAndFromNodeSize ** 2 > distanceSquaredBetweenNodes; diff --git a/packages/products/src/abstract-syntax-trees/MainView.vue b/packages/products/src/abstract-syntax-trees/MainView.vue index 98438e0b..39ae2cba 100644 --- a/packages/products/src/abstract-syntax-trees/MainView.vue +++ b/packages/products/src/abstract-syntax-trees/MainView.vue @@ -99,9 +99,9 @@