← Back to Course

Module 17

Transitions & Animation

Part B

Print vs Web

09

undefined

undefined

Part C

Science & Psychology

10

undefined

undefined

undefined
Motion Perception

undefined

undefined
Attention & Motion

undefined

undefined
Natural Motion

undefined

Part D

Real-World Examples

11

Animation in the Wild

How top products use motion purposefully.

Parallax Scroll

Products float as you scroll

Principles Identified:
Purpose Animation reveals product details progressively
Performance GPU-accelerated transforms only
Restraint Motion stops when not scrolling

Gradient Animation

Subtle, continuous motion

Principles Identified:
Subtlety Slow, gentle gradient shifts
Brand Signature animated gradients
Performance CSS-only, no JavaScript

Micro-interactions

Every click has feedback

Principles Identified:
Feedback Button presses, checkmarks, transitions
Speed 100-200ms for instant feel
Consistency Same easing throughout

Part E

Common Failures

12

Animation Anti-Patterns

Common mistakes that hurt user experience.

Failure: Too Slow

transition: 1.5s

User waits... and waits...

Fix: Keep transitions under 400ms

transition: 0.2s

Snappy and responsive

Failure: Animating Layout

width: 100px → 200px

Triggers reflow, janky at 60fps

Fix: Only animate transform and opacity

transform: scaleX(2)

GPU-accelerated, smooth

Failure: No Motion Preference

Animations everywhere

Vestibular disorders triggered

Fix: Respect prefers-reduced-motion

@media (prefers-reduced-motion) {

* { animation: none; }

}

Failure: Infinite Loops

🔄 Spinning forever

Distracting, drains battery

Fix: Limit continuous animation

Load → Spin → Stop

Animation has purpose and end

Part F

Visual Tests

13

Animation Testing

How to ensure animations are performant and accessible.

01

60fps Test

Tests: Performance

Open DevTools Performance tab. Record while triggering animations. Look for dropped frames (red). Target: solid 60fps green bars.

Red = dropped frame

02

Paint Flash

Tests: Repaints

DevTools → More tools → Rendering → Paint flashing. Green flashes show repaints. Animations should NOT cause large green areas - only the animated element.

Only animated element should flash

03

Reduced Motion

Tests: Accessibility

Enable reduced motion in OS settings. Reload your site. All animations should be disabled or significantly reduced. Essential functionality must still work.

System Preferences → Accessibility

→ Display → Reduce motion

04

Battery Test

Tests: Efficiency

Check CPU/GPU usage during animations. Continuous animations should use minimal resources. Test on mobile devices where battery matters most.

🔋

Monitor Activity Monitor / Task Manager

Part G

CSS Implementation

14

Animation Implementation

Production-ready CSS for smooth animations.

.button {
  background: #3b82f6;
  transform: translateY(0);
  transition: 
    transform 0.15s ease-out,
    background 0.15s ease-out;
}

.button:hover {
  background: #2563eb;
  transform: translateY(-2px);
}

.button:active {
  transform: translateY(0);
  transition-duration: 0.05s;
}
Button Hover via CSS
  • transform: translateY - GPU-accelerated vertical movement
  • 0.15s ease-out - Quick, decelerating feel
  • :active shorter - Instant feedback on click
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in {
  animation: fadeIn 0.3s ease-out forwards;
}
Fade In via CSS
  • opacity + transform - Both are cheap to animate
  • ease-out - Decelerates as element arrives
  • forwards - Keeps final state after animation
.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid #e5e5e5;
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
Loading Spinner via CSS
  • border technique - Lightweight, no images needed
  • linear timing - Constant speed for spinners
  • transform: rotate - GPU-accelerated rotation
/* Default: with motion */
.element {
  transition: transform 0.3s ease-out;
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  .element {
    transition: none;
  }
  
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
Reduced Motion via CSS
  • prefers-reduced-motion - Respects OS accessibility setting
  • transition: none - Disables transitions
  • animation-duration: 0.01ms - Effectively disables animations

Part H

Self-Assessment

15

Self-Assessment

Test your understanding of animation principles.

Q1

Why should you only animate transform and opacity?

Click to reveal
Q2

What timing function should you use for elements entering the screen?

Click to reveal
Q3

What is the ideal duration range for UI transitions?

Click to reveal
Q4

How do you respect users who prefer reduced motion?

Click to reveal
Q5

What's the difference between transitions and keyframe animations?

Click to reveal

Key Takeaways

Performance First undefined

undefined

Timing Matters undefined

undefined

Accessibility Required undefined

undefined

Purpose Over Decoration undefined

undefined

Test on Real Devices undefined

undefined