Import these from @grafloria/renderer.
Functions
applyNodePreset
Apply a preset to a node
tsfunction applyNodePreset(node: NodeModel, preset: typeof AnimationPresets.NODE[keyof typeof AnimationPresets.NODE]): NodeModel
Parameters
node: Node to apply preset topreset: Preset configuration
Returns Modified node (mutation)
applyWorkflowPreset
Apply a workflow preset to a node
tsfunction applyWorkflowPreset(
node: NodeModel,
preset: typeof AnimationPresets.WORKFLOW[keyof typeof AnimationPresets.WORKFLOW]
): NodeModel
Parameters
node: Node to apply preset topreset: Workflow preset configuration
Returns Modified node (mutation)
buildAnimationClass
Build animation class string from individual parts
tsfunction buildAnimationClass(...parts: (string | undefined | null | false)[]): string
Parameters
parts: Array of class name parts (filters out empty/undefined)
Returns Space-separated class string
calculateAnimationDuration
Calculate animation duration based on speed setting
tsfunction calculateAnimationDuration(
baseSpeed: 'slow' | 'normal' | 'fast' | undefined,
baseDuration: number = 1
): number
Parameters
baseSpeed: Base animation speed ('slow' | 'normal' | 'fast')baseDuration: Base duration in seconds (default: 1)
Returns Duration in seconds
cancelAnimFrame
Cancel animation frame wrapper with fallback
tsfunction cancelAnimFrame(id: number): void
Parameters
id: Request ID to cancel
canCoexist
Check if two animations can coexist Some animations can run simultaneously (e.g., border + status)
tsfunction canCoexist(a: AnimationDescriptor, b: AnimationDescriptor): boolean
createAnimationCustomProperties
Create CSS custom properties object for animation
tsfunction createAnimationCustomProperties(options: {
duration?: number;
strokeWidth?: number;
color?: string;
glowColor?: string;
}): Record<string, string>
Parameters
options: Animation options
Returns Object with CSS custom properties
createLinkAnimation
Create link animation configuration
tsfunction createLinkAnimation(
type: 'marching-ants' | 'flow' | 'pulse' | 'none',
options: {
speed?: 'slow' | 'normal' | 'fast';
direction?: 'forward' | 'reverse';
duration?: number;
} = {}
): LinkAnimation
Parameters
type: Animation typeoptions: Additional options
Returns LinkAnimation object
createPriorityResolver
Create a priority resolver with default configuration
tsfunction createPriorityResolver(
config?: Partial<PriorityResolverConfig>
): AnimationPriorityResolver
debounce
Debounce function for performance optimization Useful for animation updates during resize/scroll
tsfunction debounce<T extends (...args: any[]) => any>(
func: T,
wait: number
): (...args: Parameters<T>) => void
Parameters
func: Function to debouncewait: Wait time in milliseconds
Returns Debounced function
generateGradientBorderCSS
Generate dynamic CSS for gradient border animation
tsfunction generateGradientBorderCSS(colors: string[], duration: number = 3): string
Parameters
colors: Array of gradient colorsduration: Animation duration in seconds
Returns CSS string for gradient animation
getCoexistingAnimations
Get all animations that can coexist together Returns a set of compatible animations
tsfunction getCoexistingAnimations(
animations: AnimationDescriptor[]
): AnimationDescriptor[]
getDefaultPriority
Get default priority for an animation descriptor
tsfunction getDefaultPriority(descriptor: AnimationDescriptor): number
getLinkAnimationFromPreset
Get link animation from a preset
tsfunction getLinkAnimationFromPreset(
preset: typeof AnimationPresets.WORKFLOW[keyof typeof AnimationPresets.WORKFLOW] |
typeof AnimationPresets.ETL[keyof typeof AnimationPresets.ETL]
): LinkAnimation
Parameters
preset: Preset with link configuration
Returns Link animation configuration
getOptimalAnimationSettings
Get optimal animation settings based on browser performance
tsfunction getOptimalAnimationSettings(): {
maxAnimatedEdges: number;
maxAnimatedNodes: number;
preferredAnimationType: 'simple' | 'complex';
}
Returns Recommended animation settings
isValidAnimationType
Validate animation type
tsfunction isValidAnimationType(
type: any
): type is 'marching-ants' | 'flow' | 'pulse' | 'none'
Parameters
type: Animation type to validate
Returns Whether the type is valid
isValidBorderAnimationType
Validate border animation type
tsfunction isValidBorderAnimationType(
type: any
): type is 'gradient' | 'pulse' | 'breathe' | 'shimmer' | 'none'
Parameters
type: Border animation type to validate
Returns Whether the type is valid
isValidStatus
Validate status type
tsfunction isValidStatus(
status: any
): status is 'idle' | 'pending' | 'running' | 'completed' | 'error' | 'warning'
Parameters
status: Status to validate
Returns Whether the status is valid
measureAnimationFPS
Measure animation FPS (for debugging/performance monitoring)
tsfunction measureAnimationFPS(duration: number = 1000): Promise<number>
Parameters
duration: Duration to measure in milliseconds
Returns Promise that resolves to average FPS
msToSeconds
Convert animation duration from milliseconds to seconds
tsfunction msToSeconds(milliseconds: number): number
Parameters
milliseconds: Duration in milliseconds
Returns Duration in seconds
prefersReducedMotion
Check if user prefers reduced motion
tsfunction prefersReducedMotion(): boolean
Returns Whether user prefers reduced motion
requestAnimFrame
Request animation frame wrapper with fallback
tsfunction requestAnimFrame(callback: () => void): number
Parameters
callback: Function to call on next frame
Returns Request ID
resolveAnimationConflict
Resolve conflict between multiple animations Returns the animation with the highest priority
tsfunction resolveAnimationConflict(
animations: AnimationDescriptor[]
): AnimationDescriptor | null
resolveEdgeAnimationConflict
Resolve conflict between multiple edge animations Returns the animation that should be displayed
tsfunction resolveEdgeAnimationConflict(
animations: AnimationDescriptor[]
): AnimationDescriptor | null
resolveNodeAnimationConflict
Resolve conflict between multiple node animations Returns the animation that should be displayed
tsfunction resolveNodeAnimationConflict(
animations: AnimationDescriptor[]
): AnimationDescriptor | null
secondsToMs
Convert animation duration from seconds to milliseconds
tsfunction secondsToMs(seconds: number): number
Parameters
seconds: Duration in seconds
Returns Duration in milliseconds
shouldSimplifyAnimations
Check if animation should be simplified for performance
tsfunction shouldSimplifyAnimations(
animationCount: number,
performanceThreshold: number = 50
): boolean
Parameters
animationCount: Number of currently animating elementsperformanceThreshold: Threshold for simplification (default: 50)
Returns Whether to simplify animations
supportsAnimations
Check if browser supports CSS animations
tsfunction supportsAnimations(): boolean
Returns Whether CSS animations are supported
throttle
Throttle function for performance optimization Useful for animation updates during continuous events
tsfunction throttle<T extends (...args: any[]) => any>(
func: T,
limit: number
): (...args: Parameters<T>) => void
Parameters
func: Function to throttlelimit: Time limit in milliseconds
Returns Throttled function
Classes
AnimationPriorityResolver
Animation priority resolver Advanced resolver with configuration support
tsclass AnimationPriorityResolver
Methods
constructor(config: Partial<PriorityResolverConfig> = {})resolve(animations: AnimationDescriptor[]): AnimationDescriptor[]— Resolve animations based on configurationupdateConfig(config: Partial<PriorityResolverConfig>): void— Update configurationgetConfig(): Readonly<PriorityResolverConfig>— Get current configuration
Constants
AnimationColorSchemes
Common color schemes for animations
tsconst AnimationColorSchemes: { readonly BLUE: readonly ["#3498db", "#2980b9"]; readonly GREEN: readonly ["#27ae60", "#229954"]; readonly RED: readonly ["#e74c3c", "#c0392b"]; readonly ORANGE: readonly ["#f39c12", "#e67e22"]; readonly PURPLE: readonly ["#9b59b6", "#8e44ad"]; readonly TEAL: readonly ["#1abc9c", "#16a085"]; readonly YELLOW: readonly ["#f1c40f", "#f39c12"]; readonly GRADIENT_COOL: readonly ["#667eea", "#764ba2"]; readonly GRADIENT_WARM: readonly ["#f093fb", "#f5576c"]; readonly GRADIENT_OCEAN: readonly ["#4facfe", "#00f2fe"]; readonly GRADIENT_SUNSET: readonly ["#fa709a", …
AnimationPresets
Preset configurations for common workflow states
tsconst AnimationPresets: { readonly WORKFLOW: { readonly RUNNING: { readonly node: { readonly status: "running"; readonly animateStatus: true; readonly style: { readonly animatedBorder: true; readonly borderAnimationType: "pulse"; readonly borderAnimationSpeed: 1.5; }; }; readonly link: LinkAnimation; }; readonly PROCESSING: { readonly node: { readonly status: "running"; readonly animateStatus: true; readonly style: { readonly animatedBorder: true; readonly borderAnimationType: "gradient"; readonly borderAnimationSpeed: 2; readonly borderAnimationColors: readonly ["#667eea", "#764ba2"]; }; }; …
AnimationSpeeds
Common animation speed values
tsconst AnimationSpeeds: { readonly VERY_SLOW: 0.5; readonly SLOW: 1; readonly NORMAL: 1.5; readonly FAST: 2; readonly VERY_FAST: 3; }
Interfaces
AnimationDescriptor
Animation descriptor for conflict resolution
tsinterface AnimationDescriptor
Properties
| Name | Type | Default | Description |
|---|---|---|---|
type | AnimationType | ||
priority? | number | ||
borderType? | 'gradient' | 'pulse' | 'breathe' | 'shimmer' | ||
status? | 'idle' | 'pending' | 'running' | 'completed' | 'error' | 'warning' | ||
edgeType? | 'marching-ants' | 'flow' | 'pulse' | 'dash-flow' | ||
customName? | string | ||
metadata? | Record<string, any> |
PriorityResolverConfig
Priority resolver configuration
tsinterface PriorityResolverConfig
Properties
| Name | Type | Default | Description |
|---|---|---|---|
allowCoexistence | boolean | Allow multiple animations to coexist | |
priorityOverrides? | Record<string, number> | Custom priority overrides | |
strictMode? | boolean | Strict mode: throw error on conflicts instead of resolving |
Types
AnimationType
Also has every member of String, listed on its own entry.
Animation types for priority resolution
tstype AnimationType =
| 'border'
| 'status'
| 'edge'
| 'hover'
| 'selected'
| 'custom';
Enums
AnimationPriority
Animation priority levels (higher number = higher priority)
tsenum AnimationPriority
Members
BORDER_GRADIENT = 10BORDER_SHIMMER = 15BORDER_BREATHE = 20HOVER_STATE = 30SELECTED_STATE = 35BORDER_PULSE = 40EDGE_MARCHING_ANTS = 50EDGE_FLOW = 55EDGE_PULSE = 60EDGE_DASH_FLOW = 65STATUS_PENDING = 70STATUS_RUNNING = 75STATUS_WARNING = 80STATUS_COMPLETED = 85STATUS_ERROR = 90USER_INTERACTION = 95CUSTOM_ANIMATION = 100
Was this page helpful?