← Declarative motion

Motion.tween

luastra/motion
Motion.tween(options: TweenOptions): Tween

Creates one deterministic numeric transition from a starting value to an ending value over a bounded duration and easing curve. A Tween becomes meaningful only when assigned to a supported motion channel or placed in a Sequence.

Before you use it

Add luastra/motion to this module's dependencies in luastra.json, then import it with require("luastra/motion"). Motion itself needs no capability; a visible result requires ui.render and a component that accepts the returned descriptor through its motion field.

How it fits

The function returns immutable motion data synchronously. Assign a preset MotionMap directly, or place Tween/Sequence values under supported motion channel names; the host animates without rerunning app.render on every frame.

When to use it

Use Motion.tween when you need direct control of one opacity, translation, scale, or rotation channel. Prefer a named preset when it already expresses the intended interaction and respect reduced-motion behavior supplied by the host.

Parameters

ParameterType / valuesDescription
optionsTweenOptionsStart, end, duration, and optional easing for one numeric motion channel.
options.fromnumberRequired finite value at the beginning of the transition.
options.tonumberRequired finite value at the end of the transition.
options.durationMsnumber (0..60000)Required transition duration in milliseconds.
options.easing"linear" | "easeOutCubic" | "easeInOutCubic"?Optional interpolation curve; defaults to "linear".

Returns

Tween — an immutable descriptor for one bounded numeric transition.

What happens next

A descriptor or MotionMap ready to attach to a supported UI node.

Failures and fixes

Unknown options, invalid bounds, or unsupported channels fail validation. Motion must not drive application logic; use Timer for state changes, and rely on the host to present the final state when reduced motion is enabled.

Availability

Public-source alpha API in 0.5.0-alpha; presentation follows host and reduced-motion policy.

Focused example

local Motion = require("luastra/motion")
local grow = Motion.tween { from = 1, to = 1.08, durationMs = 300, easing = "easeOutCubic" }

Complete inventory

View all pages in Declarative motion
← Previous: Motion.MotionMapNext: Motion.wait →