LavaUI docs GitHub

enum AnimationDriver

Swift

enum AnimationDriver

Steps every node with animation in flight, once per frame.

A registry rather than a tree walk: only animating nodes are visited, so an idle window does no work at all and a single animating button does not cost a traversal of the whole tree.

Sources/LavaUI/Animation.swift:191

Properties

static var isAnimating: Bool { get }

Whether any node still has an animation in flight.

Sources/LavaUI/Animation.swift:231

Methods

static func register(_ id: NodeID, step: @escaping () -> Bool)

Registers step to run once per frame for node id, replacing any stepper it already had. step returns false once the node has settled, which removes it. Also asks for the next frame, so an animation started during mount or reconcile does not wait for unrelated input.

Sources/LavaUI/Animation.swift:209

static func requestRevisibilityCheck()

Call once after a frame has emitted, i.e. after NodeVisibility was just refreshed. tick() reads visibility captured before that same frame's emitTree — one iteration stale by design — so a node whose box just scrolled, resized, or expanded into view has no wake queued yet: the tick() earlier this same iteration still saw it as off-screen and correctly asked for nothing. Without this, such a node stays frozen until some unrelated input happens to wake the loop, rather than resuming on its own next frame. A no-op once nothing is registered, and otherwise just re-arms the same 60fps wake tick() would have asked for had it seen current visibility — it does not step or mark redraw itself, so an actually-still-invisible node costs nothing beyond one harmless extra wake that tick() immediately suppresses again.

Sources/LavaUI/Animation.swift:246

static func tick()

Advances every registered animation. Everything still gets stepped — cheap, and it is what lets a [weak self] stepper on a since-deallocated node reap itself out of active even while its node was invisible — but only a visible node's progress justifies a redraw and another 60fps wake. A Canvas(continuousRedraw: true) scrolled out of view, or collapsed behind an Expand, otherwise never stops asking for one: its own stepper has no notion of "am I on screen", only of the state the widget handed it (playing/not playing). A minimized window's registrants are stepped but never counted as visible, which is the per-window form of the gate the frame loop used to apply to tick() as a whole. That gate could only say "no window is visible"; with two windows it would have let a minimized one keep asking for 60fps as long as the other was up.

Sources/LavaUI/Animation.swift:264

static func unregister(_ id: NodeID)

Removes node id's stepper, if it has one. Call when the node goes away.

Sources/LavaUI/Animation.swift:221