← Declarative motion

Motion.shake

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

Returns a short horizontal translation MotionMap that moves away from and back to the resting position. It is designed as bounded feedback rather than an ambient loop.

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.shake after a rejected guess or invalid action when the UI also exposes an accessible text or status explanation. Do not use it for ordinary errors that have not yet been caused by user action.

Parameters

ParameterType / valuesDescription
optionsany?Optional distance, duration, and easing settings for bounded feedback.
options.distancenumber (0..1000]?Optional horizontal peak distance; defaults to 8.
options.durationMsnumber (0..60000)?Duration of the first and last legs; defaults to 70 ms.
options.iterationsinteger (0..1000)?Shake cycle count; defaults to 1 and 0 means continuous.

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.shake { distance = 8, durationMs = 360 }

Complete inventory

View all pages in Declarative motion
← Previous: Motion.pulseNext: Motion.flip →