animation
Animation module: tweens numeric properties over time.
local anim = basalt.use("animation")
anim.to(label, { x = 20, y = 5 }, 0.5, "easeOut", function(el) ... end)
label:animate({ x = 20 }, 0.5) -- sugar added to ElementStandalone module: drives itself through a basalt.schedule coroutine (sleep-based, ~20 fps) and touches no core files.
Fields
| Field | Type | Description |
|---|---|---|
| easings | table<string, fun(t: number): number> | Registered easing functions |
Methods
animation.to(el, props, duration, easing, onDone)
Tweens the given numeric properties to their target values.
el (
table) The element to animateprops (
table) Target values, e.g.duration (
number, optional) Seconds, default 0.3easing (
string, optional) "linear", "easeIn", "easeOut" or "easeInOut"onDone (
function, optional) Called with the element after completionreturns handle (
table) Handle with :cancel()
Element:animate(props, duration, easing, onDone)
Sugar on Element: el:animate({x = 20}, 0.5, "easeOut", onDone) Fluent element shortcut for animation.to().
props (
table) Target property valuesduration (
number, optional) Seconds, default 0.3easing (
string, optional) Easing nameonDone (
function, optional) Completion callbackreturns handle (
table) Cancellable animation handle