anim

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 14, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package anim provides an animated spinner.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Anim

type Anim struct {
	// contains filtered or unexported fields
}

Anim is a Bubble for an animated spinner.

func New

func New(opts Settings) *Anim

New creates a new Anim instance with the specified width and label.

func (*Anim) Animate

func (a *Anim) Animate(msg StepMsg) tea.Cmd

Animate advances the animation to the next step.

func (*Anim) ElapsedSeconds

func (a *Anim) ElapsedSeconds() int

ElapsedSeconds returns the number of full seconds elapsed since the animation started, derived from the frame counter so no wall-clock call is needed.

func (*Anim) EllipsisFrame

func (a *Anim) EllipsisFrame() string

EllipsisFrame returns a cycling ellipsis string (".", "..", "...") based on the current frame counter. Advances every ~400ms regardless of label width.

func (*Anim) Render

func (a *Anim) Render() string

Render renders the current state of the animation.

func (*Anim) SetLabel

func (a *Anim) SetLabel(newLabel string)

SetLabel updates the label text and re-renders it.

func (*Anim) Start

func (a *Anim) Start() tea.Cmd

Start starts the animation.

func (*Anim) Step

func (a *Anim) Step() tea.Cmd

Step is a command that triggers the next step in the animation.

func (*Anim) Width

func (a *Anim) Width() (w int)

Width returns the total width of the animation.

type Settings

type Settings struct {
	ID          string
	Size        int
	Label       string
	LabelColor  color.Color
	GradColorA  color.Color
	GradColorB  color.Color
	CycleColors bool
}

Settings defines settings for the animation.

type StepMsg

type StepMsg struct{ ID string }

StepMsg is a message type used to trigger the next step in the animation.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL