Animation System
`DSAnimation` packages a small set of reusable springs and easing curves for interaction, layout, overlays, fades, and pulse states. The definitions below match the package presets.
Animation Presets
DSAnimation.interactive
spring(response: 0.3, damping: 0.7)
Buttons, toggles, checkboxes
DSAnimation.smooth
spring(response: 0.45, damping: 0.8)
Modals, sheets, overlays
DSAnimation.gentle
spring(response: 0.6, damping: 0.85)
List insertions, layout changes
DSAnimation.fade
easeOut(duration: 0.2)
Opacity and fade effects
DSAnimation.pulse
easeInOut(1.0).repeatForever()
Skeleton loaders, ping indicators
Usage
import SwiftUI
Button("Tap me") {
isPressed.toggle()
}
.scaleEffect(isPressed ? 0.95 : 1.0)
.animation(DSAnimation.interactive, value: isPressed)
// For layout changes
VStack {
if showDetails {
DetailView()
.transition(.opacity)
}
}
.animation(DSAnimation.gentle, value: showDetails)Spring Physics
The package uses `Animation.spring(response:dampingFraction:)` for the spring presets and `Animation.easeOut` / `Animation.easeInOut(...).repeatForever(...)` for utility transitions.
- •Response: How quickly the animation reaches its target
- •Damping: How much bounce (lower = more bounce)
- •`interactive` lowers response for buttons and toggles to feel snappy
- •`smooth` and `gentle` trade speed for calmer overlay and layout movement