AgentSkillsCN

emilkowal-animations-swift

SwiftUI 和 AppKit 在 Apple 平台上的动画最佳实践。适用于在 SwiftUI(iOS 17+)或 AppKit 中编写、审查或实现动画时使用。当涉及过渡、缓动、弹簧、手势、匹配几何、阶段动画器,或运动动画时,此技能将自动触发。

SKILL.md
--- frontmatter
name: emilkowal-animations-swift
description: SwiftUI and AppKit animation best practices for Apple platforms. Use when writing, reviewing, or implementing animations in SwiftUI (iOS 17+) or AppKit. Triggers on tasks involving transitions, easing, springs, gestures, matched geometry, phase animators, or motion.

SwiftUI & AppKit Animation Best Practices

Comprehensive animation guide for Apple platform interfaces, adapted from Emil Kowalski's web animation principles and Framer Motion best practices. Contains 80 rules across 10 categories targeting iOS 17+, prioritized by impact.

When to Apply

Reference these guidelines when:

  • Adding animations to SwiftUI views
  • Choosing easing curves, springs, or timing values
  • Implementing gesture-based interactions (drag, tap, long press)
  • Building transitions and navigation animations
  • Using matchedGeometryEffect for shared element transitions
  • Creating scroll-linked or parallax effects
  • Using iOS 17+ PhaseAnimator or KeyframeAnimator
  • Optimizing animation performance
  • Ensuring animation accessibility with accessibilityReduceMotion
  • Writing AppKit/macOS-specific animations

Rule Categories by Priority

PriorityCategoryImpactPrefix
1Timing Curves & EasingCRITICALease-
2Duration & TimingCRITICALtiming-
3Animation PropertiesHIGHprops-
4Transforms & EffectsHIGHtransform-
5Gesture & InteractionHIGHgesture-
6Transitions & NavigationMEDIUM-HIGHtransition-
7Scroll & ParallaxMEDIUMscroll-
8Strategic AnimationMEDIUMstrategy-
9Accessibility & PolishMEDIUMpolish-
10AppKit SpecificLOW-MEDIUMappkit-

Quick Reference

1. Timing Curves & Easing (CRITICAL)

2. Duration & Timing (CRITICAL)

3. Animation Properties (HIGH)

4. Transforms & Effects (HIGH)

5. Gesture & Interaction (HIGH)

6. Transitions & Navigation (MEDIUM-HIGH)

7. Scroll & Parallax (MEDIUM)

8. Strategic Animation (MEDIUM)

9. Accessibility & Polish (MEDIUM)

10. AppKit Specific (LOW-MEDIUM)

Key Values Reference

ValueUsage
.spring(duration: 0.3, bounce: 0.2)Standard iOS 17 spring animation
.spring(response: 0.3, dampingFraction: 0.7)Classic spring configuration
.easeOut(duration: 0.2)Standard UI transition
scaleEffect(0.97)Button press feedback
scaleEffect(0.95)Minimum enter scale (never scale to 0)
0.2 secondsDefault micro-interaction duration
0.3 secondsMaximum duration for UI animations
0.5 secondsSheet/drawer animation duration

Concept Mapping (Web to SwiftUI)

Web ConceptSwiftUI Equivalent
ease-out.easeOut or Animation.easeOut(duration:)
cubic-bezier(a,b,c,d).timingCurve(a, b, c, d, duration:)
Framer Motion spring.spring(duration:bounce:) (iOS 17+)
transform: scale(0.97).scaleEffect(0.97)
transform-origin.scaleEffect(anchor: .topLeading)
useMotionValue@State / @GestureState
AnimatePresence.transition() + .id()
layoutId.matchedGeometryEffect(id:in:)
useScrollGeometryReader + PreferenceKey
whileHover/whileTap.onHover {} / gesture modifiers
dragConstraintsDragGesture with onChange bounds
prefers-reduced-motion@Environment(\.accessibilityReduceMotion)

Reference Files

FileDescription
references/_sections.mdCategory definitions and ordering
assets/templates/_template.mdTemplate for new rules
metadata.jsonVersion and reference information