Foundations/Animations
Animation System
SwiftDS uses physics-based spring animations for natural, responsive interactions. All animations respect the user's Reduce Motion accessibility setting.
Animation Presets
DSAnimation.interactive
Snappy spring (0.3s response, 0.7 damping)
Buttons, toggles, interactive elements
DSAnimation.smooth
Smooth spring (0.45s response, 0.8 damping)
Modals, sheets, overlays
DSAnimation.gentle
Gentle spring (0.6s response, 0.85 damping)
List inserts, layout changes
DSAnimation.fade
Quick easeOut (0.2s duration)
Opacity transitions, fade effects
DSAnimation.pulse
Slow breathe (1.0s easeInOut, repeating)
Skeleton loaders, pulse effects
Usage
Example
import SwiftUI
Button("Tap me") {
isPressed.toggle()
}
.scaleEffect(isPressed ? 0.95 : 1.0)
.animation(.interactive, value: isPressed)
// For layout changes
VStack {
if showDetails {
DetailView()
.transition(.opacity)
}
}
.animation(.gentle, value: showDetails)Spring Physics
Spring animations use response (duration) and damping (bounciness) parameters:
- •Response: How quickly the animation reaches its target
- •Damping: How much bounce (lower = more bounce)
- •Interactive elements use lower response for snappiness
- •Overlays use higher damping for smoothness