Skip to main content

with_animation

Function with_animation 

Source
pub fn with_animation<R>(spec: AnimSpec, f: impl FnOnce() -> R) -> R
Expand description

Explicitly animate every state change made in f — Day’s equivalent of SwiftUI’s withAnimation. The mutation runs inside a day_reactive::batch; that batch’s synchronous fixpoint drain (bindings → patch, plus the turn-end layout → set_frame) executes while spec is ambient, so the resulting native updates carry the animation intent and the toolkit animates them on its own compositor. Nesting overrides; the previous ambient restores after.

Edge case: if called from inside an in-progress drain (rare — mutating within a reactive effect), the batch defers to the ongoing drain and the intent is not captured; the change then applies instantly. This matches SwiftUI’s transaction boundaries.

Day API ↩ Guides· daybrite.dev