Build with XuiView Markdown

Animate layout and drawing

Choose what moves before choosing an easing curve. A growing panel, a sliding card, and a moving marker may look similar, but they ask different work from the view tree.

Use the runnable dot in Frames and time as the starting point. Its normalized position changes, but the track and the view's frame stay fixed. Only the Canvas picture needs to update.

Animate Canvas geometry for a drawing

The dot computes its center from Frame.Width and position inside RenderCore. AnimateCore changes position and calls InvalidateRender. This is a good fit for a chart marker, dial hand, selection glow, or progress visualization whose surrounding layout should stay still.

Keep the normalized state independent of the current pixel width. If the window resizes mid-transition, the renderer uses the new frame without restarting the motion or carrying an old pixel endpoint into a new layout.

Do not update the position from RenderCore; a screenshot or extra repaint must not advance the animation.

Animate a presentation transform for a whole child

Wrap the content in TransformView when the entire child should slide or scale while siblings keep their places. The following is a fragment for an animation callback; host is a TransformView, and offset is an NFloat computed by the transition:

host.Transform = AffineTransform.Translate((offset, 0));

The transform setter invalidates drawing and hit testing. It does not change the child's layout rectangle. Unlike applying only a Canvas translation, the host keeps pointer positions aligned with the transformed content. See the complete runnable transformed card.

Use an invertible transform throughout an interaction. Scale toward a small positive value or stop input deliberately; do not use zero scale and then expect inverse coordinate mapping to work.

Animate layout when neighbors must respond

If expanding a panel must push later content down, its measured height really changes. Store the animated height and invalidate measure and arrangement as needed. A property implemented with SetViewProperty handles that invalidation path. For a container whose outer size stays fixed but whose children move, invalidate its arrangement and rendering.

The InsetPanel offers a concrete experiment: feed a timed value into its Inset property. The child receives less space as the inset grows, and the panel's desired size changes. Compare that with scaling the same child through TransformView: scaling changes its presentation while its layout request stays unchanged.

Layout animation can repeatedly measure text and reflow siblings. That cost can be justified by the desired behavior, but avoid requesting full layout for a color fade or fixed-size marker. Profile the actual page rather than assuming every animated property needs the same invalidation.

At completion, store the final value exactly and stop requesting frames. Apply the same cleanup and reduced-motion policy to all three paths.