Table of Contents

Class ViewportAnimation

Namespace
FlowGraph.Avalonia.Animation
Assembly
FlowGraph.Avalonia.dll

Animates viewport transitions (pan and zoom).

public class ViewportAnimation : ICategorizedAnimation, IAnimation
Inheritance
ViewportAnimation
Implements
Inherited Members

Constructors

ViewportAnimation(ViewportState, double, double, double, double, Func<double, double>?, Action?)

Creates a new viewport animation.

public ViewportAnimation(ViewportState viewport, double targetZoom, double targetOffsetX, double targetOffsetY, double duration = 0.3, Func<double, double>? easing = null, Action? onComplete = null)

Parameters

viewport ViewportState

The viewport to animate.

targetZoom double

Target zoom level.

targetOffsetX double

Target X offset.

targetOffsetY double

Target Y offset.

duration double

Animation duration in seconds.

easing Func<double, double>

Easing function (defaults to EaseOutCubic).

onComplete Action

Callback when animation completes.

Properties

AffectedNodeIds

Gets the IDs of nodes affected by this animation (if applicable).

public IReadOnlyCollection<string> AffectedNodeIds { get; }

Property Value

IReadOnlyCollection<string>

Category

Gets the category of this animation.

public AnimationCategory Category { get; }

Property Value

AnimationCategory

IsComplete

Gets whether the animation has completed.

public bool IsComplete { get; }

Property Value

bool

Methods

Cancel()

Called when the animation completes or is cancelled.

public void Cancel()

CenterOn(ViewportState, Point, double, Func<double, double>?, Action?)

Creates a viewport animation to center on a canvas point.

public static ViewportAnimation CenterOn(ViewportState viewport, Point canvasPoint, double duration = 0.3, Func<double, double>? easing = null, Action? onComplete = null)

Parameters

viewport ViewportState
canvasPoint Point
duration double
easing Func<double, double>
onComplete Action

Returns

ViewportAnimation

FitToBounds(ViewportState, Rect, double, double, Func<double, double>?, Action?, double, double)

Creates a viewport animation to fit bounds in view.

public static ViewportAnimation FitToBounds(ViewportState viewport, Rect bounds, double padding = 50, double duration = 0.3, Func<double, double>? easing = null, Action? onComplete = null, double minZoom = 0.1, double maxZoom = 2)

Parameters

viewport ViewportState

The viewport to animate.

bounds Rect

The bounds to fit.

padding double

Padding around the bounds.

duration double

Animation duration in seconds.

easing Func<double, double>

Easing function.

onComplete Action

Callback when animation completes.

minZoom double

Minimum zoom level (default: 0.1).

maxZoom double

Maximum zoom level (default: 2.0).

Returns

ViewportAnimation

Update(double)

Updates the animation with the elapsed time since the last frame.

public void Update(double deltaTime)

Parameters

deltaTime double

Time elapsed since last update in seconds.

ZoomTo(ViewportState, double, Point?, double, Func<double, double>?, Action?)

Creates a viewport animation to zoom to a level at a specific screen point.

public static ViewportAnimation ZoomTo(ViewportState viewport, double targetZoom, Point? zoomCenter = null, double duration = 0.2, Func<double, double>? easing = null, Action? onComplete = null)

Parameters

viewport ViewportState

The viewport to animate.

targetZoom double

Target zoom level (will be clamped by viewport's SetZoomDirect).

zoomCenter Point?

Screen point to zoom towards.

duration double

Animation duration in seconds.

easing Func<double, double>

Easing function.

onComplete Action

Callback when animation completes.

Returns

ViewportAnimation