Skip to content

About

Appear animation transition View for SwiftUI πŸš€

Resources

Stars

12 stars

Watchers

1 watching

Forks

Latest commit

Β 

History

11 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

DelayedTransitionView

Appear animation transition View for SwiftUI


Installation

Swift Package Manager is a tool for managing the distribution of Swift frameworks. It integrates with the Swift build system to automate the process of downloading, compiling, and linking dependencies.

Using Xcode

To integrate using Xcode 13, open your Project file and specify it in Project > Package Dependencies using the following URL:

https://github.com/stonko1994/DelayedTransitionView.git

Usage

import DelayedTransitionView

Add a DelayedTransitionView to your view. This view acts as container view for all views that should be animated.

DelayedTransitionView {
    ...
}

The DelayedTransitionView takes additional configuration properties. (See code documentation for details)

Use the .delayedPresentation(viewIndex: x) view modifier to specify which views should be animated.

DelayedTransitionView {
    VStack {
        Spacer()
        Text("First view")
            .delayedPresentation(viewIndex: 0)
        Spacer()
        Text("Second view")
            .delayedPresentation(viewIndex: 1)
        Spacer()
        Text("Third view")
            .delayedPresentation(viewIndex: 2)
        Spacer()
    }
}

In this example only the Text views will appear be animated.

For more control over the individual animations, checkout the additional configuration properties. (See code documentation for details) It is possible to use the same viewIndex for multiple views if they should appear at the same time. Also it does not need to start with 0

Replaying the animation

By default, DelayedTransitionView animates on its first appearance. Set replayOnReappear to true to replay the entrance animation when the container reappears, for example when switching between tabs:

DelayedTransitionView(replayOnReappear: true) {
    Text("Tab content")
        .delayedPresentation(viewIndex: 0)
}

Leave replayOnReappear disabled when returning to a screen should feel like continuing where you left off. For example, returning from match details to a scrolled results list usually does not need another entrance animation. The default of false preserves the existing behavior for callers that do not specify this option.

When replay is enabled, visibility resets without animation when the container disappears. The next appearance uses the configured entrance animation without recreating the content.

Replay follows the container's lifecycle, not each child's appearance. To replay when switching tabs while preserving content when navigating back from a detail screen, place DelayedTransitionView around the tab's entire NavigationStack. Placing it inside the stack's root content also replays when returning from a detail screen.

Example


Buy Me A Coffee

About

Appear animation transition View for SwiftUI πŸš€

Resources

Stars

12 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages