Skip to content

Instantly share code, notes, and snippets.

@mishimay
Created May 30, 2022 16:24
Show Gist options
  • Save mishimay/ff8769f873d87cc64e234500b0a60efd to your computer and use it in GitHub Desktop.
Save mishimay/ff8769f873d87cc64e234500b0a60efd to your computer and use it in GitHub Desktop.
import SwiftUI
struct ContentView: View {
@State var isShrinked = false
@State var response: CGFloat = 1
@State var dampingFraction: CGFloat = 0.5
@State var blendDuration: CGFloat = 0
var body: some View {
VStack {
Circle()
.padding(50)
.foregroundColor(.purple)
.scaleEffect(isShrinked ? 0.5 : 1)
.animation(.spring(response: response, dampingFraction: dampingFraction, blendDuration: blendDuration), value: isShrinked)
Text("response: " + response.description)
Slider(value: $response, in: 0...2)
Text("dampingFraction: " + dampingFraction.description)
Slider(value: $dampingFraction, in: 0...2)
Text("blendDuration: " + blendDuration.description)
Slider(value: $blendDuration, in: 0...5)
Button("Animate") {
withAnimation {
isShrinked.toggle()
}
}
}
.padding()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment