Hello there!
I'm excited to share VDAnimation, a library that makes complex SwiftUI animations simple through a declarative API.
What it offers:
- Compose animations sequentially or in parallel with minimal code
- Control timing, curves, and duration with precision
- Animate custom types with built-in interpolation support
- Create interactive, controllable animations
Some background:
- This is the second iteration of the library; the first version supported both UIKit and SwiftUI but relied on several hacks. I'm focusing solely on SwiftUI for now, though UIKit support may return in the future.
- VDAnimation 2.0 is a Swift conversion of my ClojureDart library for Flutter animations: flutter-cljd/docs/Animations.md at main · dankinsoid/flutter-cljd · GitHub
Some examples:
WithMotion(_state) { value in
Circle()
.fill(value.color)
.scaleEffect(value.scale)
.position(value.position)
} motion: {
Sequential {
Parallel()
.position { To(CGPoint(x: 200, y: 200)) }
.color { To(.red) }
.duration(1.0)
Parallel(\.scale) {
To(1.0)
}
}
.autoreverse()
}
What sets it apart from SwiftUI animations:
VDAnimation provides a much more open and flexible API. For example:
Curve
is essentially a function(Double) -> Double
, making custom easing trivial- The interpolation function (
lerp
) can be customized for any type - The composition model allows for complex animation sequences
Current status:
The library isn't fully tested yet, and there are some known minor issues I'm working through.