• Stars
    star
    692
  • Rank 65,341 (Top 2 %)
  • Language
    Swift
  • License
    GNU General Publi...
  • Created over 2 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

This repository serves as your reference and complete guide for SwiftUI Spring Animations. It demonstrates use cases for the various types of spring animations and spring parameters. No more guessing the values of the parameters for spring animations you create for your next iOS app.

SwiftUI Spring Animations Cheat Sheet for Developers

Try the new Spring Animation in SwiftUI: Snippet

Try the new Spring Animation in SwiftUI

Animate chat bubbles an extra bounce spring

Animate chat bubbles an extra bounce spring

Springy Duo: Available soon

Springy Duo

Download and try the companion Mac App: MotionScape - Animation Studio

Check the companion open-source project: MotionScape - Animation Studio

Realistic Chain: Swift file

Realistic Chain

Unlock the secrets of iOS spring animations using SwiftUI. Learn all the SwiftUI spring animation types, understand their parameters, and discover how to create organic and fine-grained spring animations to enhance the user experience of your next iOS app.

Watch the video: (YouTube tutorial)

HSwiftUI spring animation parameters

A Chained Spring: Swift file

Chained Spring

A Bouncy Transition: Swift file

Bouncy Transition

Transition a hamburger menu to a back icon Swift file

 Transition a hamburger menu to a back icon


SwiftUI Spring Animation Types

1 .spring()

A spring with no parameters. It applies gentle and sensible spring-feel to the object you want to animate.

Menu - Close icon transition: Swift file

Menu - Close icon

2 .interactiveSpring()

An interactive spring with no parameters. This creates a spring animation with high stiffness and low response. It makes the animation is less snappy:

Menu - Close icon transition: Swift file

Menu - Close icon

3 .interpolatingSpring(stiffness, damping)

This allows you to create a spring animation that is based on stiffness and damping.

  • Stiffness: It is defined as the tensile strength of the spring. A higher stiffness will result in snappier animations. This affects the force applied to the object
    and changes how quickly the object moves towards its target.
  • Damping: You can think of damping as the braking of a car or the back-drag frictional force on the surface the object is resting on. Its purpose is to stop the object over time. It also affects the ability to overshoot the object. Hint: Start with a damping of 15 and stiffness of 170. Reducing the
    damping for example, to a value of 5 will create a spring animation that has higher bounciness.

Chat message reactions: Swift file

Chat message reactions

4 .interpolatingSpring(mass, stiffness, damping, initialVelocity)

This allows you to create a spring animation that is based on mass, stiffness, damping, and initial velocity. Default values: .interpolatingSpring (mass: Double = 1.0, stiffness: Double, damping: Double, initialVelocity: Double = 0.0).

  • Mass: Think of mass as the weight of the object animating. It changes the inertial of the object attached to the spring. That is the willingness of an object to move or stop moving. It is conceptually heavier and can be used to create a spring animation that overshoots. The heavier the mass, the longer it takes to move the object, speed it up, and slow it down.
  • Initial Velocity: The initial velocity is defined as the speed at which the animation object changes at the beginning of the animation. The default initial velocity is set to zero. It is measured in units per second of the animation.

Chat message reactions (Heart icon): Swift file

Chat message reactions

5 .spring(response, dampingFraction, blendDuration)

This allows you to create a spring animation that is based on response, damping fraction, and blend duration. Default values: .spring (response: Double = 0.55, dampingFraction: Double = 0.825, blendDuration: Double = 0). A higher response value will slow down the animation. A lower response speeds it up.

  • Response: It controls how quickly an animating property value will try and get to a target. You can use the response to create an infinitely-stiff spring by setting its value to zero.

  • Damping Fraction: Damping fraction causes a gradual reduction in the spring's oscillation. Using damping fraction, you can define how rapidly the
    oscillations decay from one bounce to the next. Additionally, you can damp the spring in the following ways:

    Chat message reactions

    • Over Damping: Set the damping fraction to a value greater than 1. It lets the object you are animating, quickly return to the rest position.
    • Critical Damping: Set the damping fraction = 1. It lets the object return to the rest position within the shortest possible time.
    • Under Damping: Set the damping fraction to be less than 1. It lets the object overshoot multiple times passing the rest position and gradually reaching the rest position.
    • Undamped: Set the damping fraction = 0. This lets the object oscillate forever.
  • Blend Duration: Blend duration is a frame of time during which a previous animation stops and the next animation starts. Changing the blend duration of any of the examples in this repository, does not produce any visual change. This makes it difficult to see what it actually does.

Chat message reactions (Thumbs up icon): Swift file

Chat message reactions

6 .interactiveSpring(response, dampingFraction, blendDuration)

This allows you to create a spring animation that is based on response, damping fraction, and blend duration. Default values: interactiveSpring (response: Double = 0.15, dampingFraction: Double = 0.86, blendDuration: Double = 0.25). You can use this spring as an alternative to .spring(response, dampingFraction, blendDuration). Always start with the default values above. To check the default values in XCode, Control-click the spring modifier and select "Show Quick Help". The thumbs down animation below uses this spring. The damping fraction is inversely proportional to the springiness of the animation. Reducing the default damping fraction will make the animation bouncier. As mentioned in step 5 above, blend duration has no visible effect on the spring, at the time of writing this article.

Chat message reactions (Thumbs down icon): Swift file

Chat message reactions


SwiftUI Spring Animation Properties and Effects

Damping Fraction: High, medium, low, and no bounce

Swift file Damping Fraction

Stiffness Bounce: High, low, medium, and very low stiffness

Swift file Stiffness Bounc

Varying Stiffness and Damping: Stiff, gentle, wobble, and no wobble

Swift file Damping Fraction


SwiftUI Spring Animation Examples

Proceed with TouchID: Swift file

Proceed with TouchID

Text Spring 1: Swift file

Text Spring 1

Heart Icon Animation: Twitter Like Reaction Clone Swift file (coming soon)

Heart Icon Animation: Twitter Like Reaction Clone

Animated Font Weight:

import SwiftUI

struct AnimateFont: View {
    @State private var isMagicallyMoving = false
    
    var body: some View {
        Text("Animate SwiftUI Text Like Your Boss' Boss!")
            .font(isMagicallyMoving ? .title : .largeTitle)
            //.fontWeight(isMagicallyMoving ? .black : .ultraLight)
            .multilineTextAlignment(.center)
            .foregroundColor(isMagicallyMoving ? .indigo : .cyan)
            .animation(.interpolatingSpring(stiffness: 170, damping: 15).repeatForever(autoreverses: true), value: isMagicallyMoving)
            .onAppear {
                isMagicallyMoving.toggle()
            }
    }
}

Text Spring 2: Swift file

Text Spring 2

Chat Emojis: Swift file

Chat Emojis

Draggable Menu ( Inapired by Hackingwithswift): Swift file

Draggable Menu

Silent Mode: On

Animate a bell to fall and rotate after falling. It is similar to the iOS silent mode (on) animation. Since this animation emulates the presence of sound, it uses a very low damping to create a high bounce. Swift file Silent Mode: On

Silent Mode: Off

Animate a slashed bell to fall and rotate after falling. It uses a rectangular mask to show and hide the bell icon. Since this animation simulates the absence of sound, it uses moderate damping to prevent the bell from bouncing. Swift file Silent Mode: Off

Position Spring Animation

Animate a ball's position so that it appears to be pulled towards a target by a spring. Swift file Position Spring Animation

Scale Spring Animation

Create a spring animation that bounces a ball into view by animating its scale fromΒ 1Β toΒ 2. Swift file Scale Spring Animation

Recording Spring Animation:

Create a recording effect using different springs. Swift file Create a recording effect using different springs.

Animate a photo preview to its fill view

Swift file  Animate a photo preview to full view

Zoom a photo from its gallery

Swift file  Zoom a photo from gallery

Animate a photo from its fit view to a fullscreen view

Swift file  Animate a photo from its fit view to a fullscreen view

Animate a ball to fall and bounce

Swift file Animate a ball to fall and bounce

Animate a bell to rotate with springiness

Swift file Animate a bell to rotate with springiness


** Related Links **

More Repositories

1

Winds

A Beautiful Open Source RSS & Podcast App Powered by Getstream.io
JavaScript
8,813
star
2

stream-chat-android

πŸ’¬ Android Chat SDK ➜ Stream Chat API. UI component libraries for chat apps. Kotlin & Jetpack Compose messaging SDK for Android chat
Kotlin
1,443
star
3

vg

Virtualgo: Easy and powerful workspace based development for go
Go
1,311
star
4

whatsApp-clone-compose

πŸ“± WhatsApp clone project demonstrates modern Android development built with Jetpack Compose and Stream Chat/Video SDK for Compose.
Kotlin
1,254
star
5

stream-react-example

Use React and Redux to build your own feature-rich and scalable social network app! Visit cabin.getstream.io for an overview of all 8 tutorials and a live demo.
HTML
923
star
6

stream-chat-flutter

Flutter Chat SDK - Build your own chat app experience using Dart, Flutter and the Stream Chat Messaging API.
Dart
839
star
7

stream-chat-react-native

πŸ’¬ React-Native Chat SDK ➜ Stream Chat. Includes a tutorial on building your own chat app experience using React-Native, React-Navigation and Stream
TypeScript
792
star
8

purposeful-ios-animations

Meaningful iOS animations built to inspire you in creating useful animations for your apps. Each of the animations here was cloned with SwiftUI. Have you seen an app animation you love to rebuild and add to this repo?, contact [@amos_gyamfi](https://twitter.com/amos_gyamfi) and [@stefanjblos](https://twitter.com/stefanjblos) on Twitter.
Swift
763
star
9

stream-chat-swift

πŸ’¬ iOS Chat SDK in Swift - Build your own app chat experience for iOS using the official Stream Chat API
Swift
750
star
10

webrtc-android

πŸ›°οΈ A versatile WebRTC pre-compiled Android library that reflects the recent WebRTC updates to facilitate real-time video chat for Android and Compose.
Kotlin
578
star
11

stream-chat-react

React Chat SDK ➜ Stream Chat πŸ’¬
TypeScript
552
star
12

awesome-saas-services

A curated list of the best in class SaaS services for developers and business owners.
475
star
13

stream-django

Django Client - Build Activity Feeds & Streams with GetStream.io
Python
453
star
14

sketchbook-compose

🎨 Jetpack Compose canvas library that helps you draw paths, images on canvas with color pickers and palettes.
Kotlin
442
star
15

avatarview-android

✨ Supports loading profile images with fractional styles, shapes, borders, indicators, and initials for Android.
Kotlin
432
star
16

webrtc-in-jetpack-compose

πŸ“± This project demonstrates WebRTC protocol to facilitate real-time video communications with Jetpack Compose.
Kotlin
402
star
17

stream-video-android

πŸ“² Android Video SDK. Stream's versatile Core + Compose UI component libraries that allow you to build video calling, audio room, and, live streaming apps based on Webrtc running on Stream's global edge network.
Kotlin
374
star
18

AvengersChat

πŸ’™ Android sample Avengers chat application using Stream Chat SDK based on MVVM (ViewModel, Coroutines, Room, Hilt, Repository) architecture.
Kotlin
367
star
19

stream-draw-android

πŸ›₯ Stream Draw is a real-time multiplayer drawing & chat game app built entirely with Jetpack Compose.
Kotlin
341
star
20

stream-chat-swiftui

SwiftUI Chat SDK ➜ Stream Chat πŸ’¬
Swift
329
star
21

stream-js

JS / Browser Client - Build Activity Feeds & Streams with GetStream.io
JavaScript
329
star
22

effects-library

The Effects Library allows developers to create sophisticated and realistic particle systems such as snow, fire, rain, confetti, fireworks, and smoke with no or minimal effort.
Swift
324
star
23

react-native-example

React Native Activity Feed example application
JavaScript
321
star
24

stream-laravel

Laravel Client - Build Activity Feeds & Streams with GetStream.io
PHP
314
star
25

flutter-samples

A collection of sample apps that use Stream
Dart
298
star
26

stream-rails

Rails Client - Build Activity Feeds & Streams with GetStream.io
Ruby
257
star
27

Streamoji

:godmode: Custom emoji rendering library for iOS apps with support for GIF & still images - plug-in extension for UITextView - performance, cache βœ… - Made with πŸ’˜ by @GetStream
Swift
248
star
28

react-native-bidirectional-infinite-scroll

πŸ“œ React Native - Bidirectional Infinite Smooth Scroll
TypeScript
220
star
29

WhatsApp-Clone-Android

Tutorial which teaches you how to build a whatsapp chat clone on android using Kotlin, viewmodels, navigation component and Stream
Kotlin
218
star
30

butterfly

πŸ¦‹ Butterfly helps you to build adaptive and responsive UIs for Android with Jetpack WindowManager.
Kotlin
214
star
31

slack-clone-react-native

Build a slack clone using react-native, Stream and react-navigation
JavaScript
206
star
32

react-native-activity-feed

Official React Native SDK for Activity Feeds
JavaScript
194
star
33

motionscape-app

MotionScape is your animations playground as a developer. You can see all animations and their parameters in effect with beautifully designed and handcrafted animation examples.
Swift
167
star
34

Android-Samples

πŸ“• Provides a list of samples that utilize modern Android tech stacks and Stream Chat SDK for Android and Compose.
Kotlin
159
star
35

node-express-mongo-api

Starter project for a REST API with Node.js, Express & MongoDB πŸ”‹
JavaScript
151
star
36

stream-chat-js

JS / Browser Client - Build Chat with GetStream.io
TypeScript
149
star
37

meeting-room-compose

πŸŽ™οΈ A real-time meeting room app built with Jetpack Compose to demonstrate video communications.
Kotlin
141
star
38

stream-php

PHP Client - Build Activity Feeds & Streams with GetStream.io
PHP
139
star
39

stream-log

πŸ›₯ Stream Log is a lightweight and extensible logger library for Kotlin Multiplatform.
Kotlin
136
star
40

react-activity-feed

Stream React Activity Feed Components
TypeScript
136
star
41

stream-python

Python Client - Build Activity Feeds & Streams with GetStream.io
Python
136
star
42

flat-list-mvcp

"maintainVisibleContentPosition" prop support for Android react-native
TypeScript
133
star
43

stream-node-orm

NodeJS Client - Build Activity Feeds & Streams with GetStream.io
JavaScript
131
star
44

website-react-examples

TypeScript
122
star
45

stream-video-swift

SwiftUI Video SDK ➑️ Stream Video πŸ“Ή
Swift
117
star
46

react-native-samples

A collection of sample apps built using GetStream and React Native
JavaScript
116
star
47

flutter-instagram-clone

An Instagram clone using Flutter and Stream Feeds
Dart
111
star
48

django_twitter

An example app built using getstream.io
Python
108
star
49

twitter-clone

Learn how to build a functional Twitter clone using Stream, 100ms, Algolia, RevenueCat and Mux 😎
Swift
107
star
50

accessible-inclusive-ios-animations

Provide ways to limit animations/motion people find jarring in your apps. This repo demonstrates accessible and inclusive iOS animations/motion with practical examples and best practices.
Swift
107
star
51

stream-result

🚊 Railway-oriented library to easily model and handle success/failure for Kotlin Multiplatform.
Kotlin
102
star
52

Stream-Example-Nodejs

An example app built using getstream.io
JavaScript
96
star
53

Android-Video-Samples

πŸ“˜ Provides a collection of samples that utilize modern Android tech stacks and Stream Video SDK for Kotlin and Compose.
Kotlin
88
star
54

react-native-audio-player

JavaScript
86
star
55

stream-ruby

Ruby Client - Build Activity Feeds & Streams with GetStream.io
Ruby
83
star
56

stream-tutorial-projects

This repo contains SwiftUI, Jetpack Compose, JS & React Native projects for some of the iOS and Android tutorial series in the Stream Developers YouTube channel (https://youtube.com/playlist?list=PLNBhvhkAJG6tJYnY-5oZ1JCp2fBNbVL_6).
Swift
83
star
57

stream-chat-unity

πŸ’¬ Unity Chat Plugin by Stream ➜ These assets are the solution for adding an in-game text chat system to your Unity game.
C#
83
star
58

stream-go2

GetStream.io Go client
Go
82
star
59

stream-cli

Configure & manage Stream applications from the command line. πŸš€
Go
80
star
60

mongodb-activity-feed

Activity Feed, Timeline, News Feed, Notification Feed with MongoDB, Node and CRDTs
JavaScript
77
star
61

android-video-chat

⚑️ Android Video Chat demonstrates a real-time video chat application by utilizing Stream Chat & Video SDKs.
Kotlin
76
star
62

TinyGraphQL

🌸 Simple and lightweight GraphQL query builder for the Swift language - Made with πŸ’˜ by @GetStream
Swift
76
star
63

slack-clone-expo

Slack clone using Expo, Stream and react-navigation
JavaScript
75
star
64

liveshopping-android

πŸ“Ή A demo app showcasing real-time livestreaming and messaging capabilities built with Jetpack Compose and Stream SDKs.
Kotlin
74
star
65

fullstack-nextjs-whatsapp-clone

A sample codebase showcasing Stream Chat and Video to resembling WhatsApp, using NextJS, TailwindCSS and Vercel.
TypeScript
72
star
66

stream-feed-flutter

Stream Feed official Flutter SDK. Build your own feed experience using Dart and Flutter.
Dart
69
star
67

stream-chat-go

Stream Chat official Golang API Client
Go
67
star
68

stream-video-js

GetStream JavaScript Video SDK
TypeScript
66
star
69

discord-clone-nextjs

Building a discord clone using NextJS, TailwindCSS, and the Stream Chat and Audio and Video SDKs.
TypeScript
64
star
70

SwiftUIMessagesUIClone

The SwiftUI Messages Clone consists of layout and composition clones of the iOS Messages app. It has Messages-like bubble and screen effects, reactions, and animations, all created with SwiftUI.
Swift
62
star
71

Stream-Example-Py

An example app built using getstream.io
CSS
61
star
72

encrypted-web-chat

A web chat application end-to-end encrypted with the Web Crypto API
JavaScript
59
star
73

swift-lambda

Ξ» Write HTTP services in Swift, deploy in seconds - Powered by AWS Lambda Runtime & Serverless Framework - Made with πŸ’˜ by @GetStream
Swift
57
star
74

stream-chat-python

Stream Chat official Python API Client
Python
56
star
75

stream-java

Java Client - Build Activity Feeds & Streams with GetStream.io
Java
53
star
76

stream-video-flutter

Flutter Video SDK - Build your own video app experience using Dart, Flutter and the Stream Video Messaging API.
Dart
46
star
77

Stream-Example-Parse

Stream-Example-Parse
JavaScript
46
star
78

Stream-Example-PHP

An example app built using getstream.io https://getstream.io
PHP
46
star
79

android-chat-tutorial

Sample apps for the Stream Chat Android SDK's official tutorial
Java
46
star
80

stream-meteor

Meteor Client - Build Activity Feeds & Streams with GetStream.io
JavaScript
45
star
81

SwiftUIChristmasTree

🌲 Pure SwiftUI christmas tree with yearly updates. Enjoy πŸŽ„
Swift
45
star
82

python-chat-example

Chat with Python, Django and React
JavaScript
44
star
83

stream-chat-net

Stream Chat official .NET API Client
C#
43
star
84

stream-chat-dart

Dart SDK - Build Chat with GetStream.io
Dart
42
star
85

kmp-sample-template

A minimal Kotlin & Compose Multiplatform template designed to build applications for both Android and iOS.
Kotlin
41
star
86

Stream-Example-Go-Cassandra-API

Go-powered API example using Cassandra
Go
38
star
87

Stream-Example-Rails

An example app built using getstream.io
Ruby
38
star
88

Stream-Example-Android

Java
38
star
89

foldable-chat-android

🦚 Foldable chat Android demonstrates adaptive and responsive UIs with Jetpack WindowManager API.
Kotlin
35
star
90

stream-net

NET Client - Build Activity Feeds & Streams with GetStream.io
C#
35
star
91

stream-swift

Swift client for Stream API
Swift
35
star
92

stream-chat-angular

πŸ’¬ Angular Chat SDK ➜ Stream Chat. Build a chat app with ease.
TypeScript
34
star
93

SwiftUI-open-voip-animations

SwiftUI animations and UI designs for iOS calling, meeting, audio-room, and live streaming use cases. Find something missing? Let @amos_gyamfi know on Twitter.
33
star
94

node-restify-mongo-api

Starter project for a REST API with Node.js, Restify & MongoDB πŸ”‹
JavaScript
32
star
95

stream-chat-unreal

The official Unreal SDK for Stream Chat
C++
32
star
96

build-viking-sample

Sample app for Build Viking.
Dart
31
star
97

swiftui-iMessage-clone

Swift
30
star
98

swift-activity-feed

Stream Swift iOS Activity Feed Components
Swift
29
star
99

stream-chat-ruby

Stream Chat official Ruby API Client
Ruby
29
star
100

sign-in-with-apple-swift-example

iOS + Node.js authentication using Sign in with Apple
Swift
28
star