iced-cube

Feedback

Spinner

An indeterminate loading indicator.

use iced_cube::spinner;
use iced_cube::feedback::spinner::{Size, advance};
API reference
Loading: Animates only while loading, driven by window frames.Loading: Animates only while loading, driven by window frames.
Static preview
Loading. Animates only while loading, driven by window frames.

Usage

The spinner has no clock of its own. Your app keeps the phase in its state and moves it on with advance each frame, which keeps the spinner a pure function of state and makes it easy to test.

Subscribe to iced::window::frames() only while something is loading, and return Subscription::none() otherwise. That way an idle app does not redraw at all.

Several spinners can share one phase, as the rows of a job list do. The arc steps through FRAMES fixed positions per turn and is drawn as a cached image, so any number of spinners on screen stay cheap and look the same on every renderer, including WebGL in the browser.

Examples

Sizes

Small, medium and large spinners sharing one phase.

Sizes: Small, medium and large spinners sharing one phase.Sizes: Small, medium and large spinners sharing one phase.
Static preview

API

ItemDescription
spinner(phase)Creates a spinner at a phase measured in turns, from 0.0 to 1.0.
.size(Size)Sm, Md or Lg. Defaults to Md.
advance(phase, elapsed)Returns the phase moved on by the elapsed time. One turn takes PERIOD.
Esc