← Declarative motion

Motion.flip

luastra/motion
Motion.flip(options: any?): MotionMap

Returns a rotationY MotionMap tailored to UI.FlipCard, moving between front and back angles over a bounded duration. The FlipCard host uses the channel to hide the reverse face correctly during the 3D transition.

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.flip only with UI.FlipCard when application state changes which of its two children is visible. Update the state and angle together; use a general rotation tween for single-sided objects.

Parameters

ParameterType / valuesDescription
optionsany?Front and back rotation angles plus duration and easing for UI.FlipCard.
options.fromDegfinite number?Optional initial Y-axis rotation; defaults to 0 degrees.
options.toDegfinite number?Optional final Y-axis rotation; defaults to 180 degrees.
options.durationMsnumber (0..60000)?Optional flip duration; defaults to 500 ms.
options.easing"linear" | "easeOutCubic" | "easeInOutCubic"?Optional interpolation curve; defaults to "easeInOutCubic".

Returns

MotionMap — a complete property-to-motion map that can be assigned directly to a supported component motion field.

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 motion = Motion.flip { fromDeg = 0, toDeg = 180, durationMs = 500 }

Complete inventory

View all pages in Declarative motion
← Previous: Motion.shake