Log inGet started
Package

bubbles.module

Newest version

This package holds more than this page lists. See all of its files in its world.

README.md

launcher.bubbles

How the create screen's idea bubbles move. Each bubble is a body offset from where layout puts it: it drifts a few points about its place on a slow sway of its own, pushes softly away from a bubble it meets, comes to rest under a finger and stays still until shortly after the finger lifts, follows a drag while the bubbles it meets part around it, and takes a fling's velocity and settles back. Untouched for 20 s the drift slows to half and the field is placed at most 30 times a second; untouched for 60 s it rests and states nothing more until it is touched.

Under reduced motion the field holds its packed layout: no drift, no push and no fling, and a dragged bubble is back at its place at once.

A step answers the offsets that changed, for one ui.setMotions call a frame. Everything here is pure: the screen hands it the bubbles' layout boxes, the touches, the drags and the clock, in logical points and seconds.

Example

local Bubbles = require("@builtin::modules.api.engine.launcher.bubbles")
local field = Bubbles.new(os.clock())
Bubbles.sync(field, { a = { x = 0, y = 0, w = 120, h = 52 } }, { "a" })
local placed = Bubbles.step(field, os.clock() + 1, ui.reducedMotion().reduce)
if placed then
	ui.setMotions(placed)
end