jazzychad / AnimationSequencing
git clone https://github.com/jazzychad/AnimationSequencing.git
0.0.1 · 7d ago
Choreograph SwiftUI animations into ordered sequences of steps.
—
stars, 24h
+43
stars, 7 days · #1,022
+43
stars, 30 days · #6,817
43
★ total · +43% this week
1
forks · 0 open issues
Star history starts 2026-10-20; the chart appears after the second daily snapshot.
LanguageSwift
LicenseMIT
Created2026-10-13 (7d ago)
Last push7d ago
Watchers1
OwnerUser
Links
README excerpt
# AnimationSequencing Choreograph SwiftUI animations into ordered sequences of steps. AnimationSequencing runs animations one after another, across any number of views. You make views into the *steps* of a named *sequence*, set the order the steps run in, and trigger the sequence. Each step starts as soon as the one before it finishes, so there are no delays to hand-tune, and changing one animation's duration or spring never throws off the steps that follow it. - **Sequences** of steps that each start when the previous one finishes - **Groups** of steps that run side by side and finish when all of them have finished - **Keyframe steps** built on SwiftUI's `keyframeAnimator` - **Steps anywhere in your view hierarchy**, as long as they share a coordinator - **Replays**, with one call to put every view back in its starting state - **Resilient to real view lifecycles**: steps that never appear are skipped, and views that appear after their step has run show their final state ## Contents - Requirements - Getting Started - How to Use - Examples - How It Works - Documentation - License ## Requirements - iOS 17.0+, macOS 14.0+, tvOS 17.0+, watchOS 10.0+, visionOS 1.0+ - Swift 6.2+ (Xcode 26 or later) ## Getting Started ### Installation In Xcode, choose **File → Add Package Dependencies…** and enter: [code] Or add it to the dependencies in your `Package.swift`: [code] ### Quick start This view fades in a title, then springs in a button as soon as the title has finished: [code] ## How to Use A sequence has three parts: 1. An `AnimationSequenceCoordinator`, which runs the sequence. 2. Views that are **steps** of the sequence, each with a name and an animation. 3. The **order** the steps run in, registered with the coordinator. ### Create a coordinator Create the coordinator in the view that owns the sequence, and keep it in `@State` so it lives as long as that view: [code] Steps can live anywhere in the view hierarchy, as long as they use the same coordinator. Pass it down as a property, or, because the coordinator is `@Observable`, through the environment: [code] A single coordinator can run any number of sequences, each under its own name. ### Make views into steps Apply `sequenceAnimation(coordinator:sequence:step:animation:initialSetup:animationBody:)` to each view that should animate: [code] The pattern to follow: - **Give the view's state its _final_ values as defaults.** Here, `showTitle` starts out `true`. - **Use `initialSetup` to move the view to its starting values.** It runs when the view registers its step, before the sequence reaches it. - **Animate back to the final values in the trailing closure** (`animationBody`). When the sequence reaches the step, the closure runs inside `withAnimation` with the step's animation. Keeping the final values as defaults means a view that appears after its step has already run simply shows its final state. A step finishes when its animation is *logically* complete, so a spring hands off to the nex