[G1-Sync] Manual knowledge update

This commit is contained in:
Antigravity Agent
2026-05-10 22:08:15 +09:00
parent 21ac3ed255
commit 504fd5fb42
3011 changed files with 380280 additions and 206977 deletions
@@ -2,78 +2,188 @@
id: wiki-2026-0508-성능-중심의-웹-애니메이션-및-인터랙션-구현
title: 성능 중심의 웹 애니메이션 및 인터랙션 구현
category: 10_Wiki/Topics
status: needs_review
status: verified
canonical_id: self
aliases: []
aliases: [Performant Web Animations, 60fps Web UI, GPU-Accelerated CSS, Compositor-Only Animations]
duplicate_of: none
source_trust_level: A
confidence_score: 0.92
tags: [uncategorized]
confidence_score: 0.9
verification_status: applied
tags: [web-performance, animation, css, gpu, compositor, raf, view-transitions]
raw_sources: []
last_reinforced: 2026-05-08
last_reinforced: 2026-05-10
github_commit: pending
inferred_by: Claude Opus 4.7 (auto-normalize 2026-05-08)
tech_stack:
language: typescript
framework: vanilla-web-platform
---
# [[성능 중심의 웹 애니메이션 및 인터랙션 구현|성능 중심의 웹 애니메이션 및 인터랙션 구현]]
# 성능 중심의 웹 애니메이션 및 인터랙션 구현
## 📌 한 줄 통찰 (The Karpathy Summary)
웹 애니메이션과 인터랙션은 사용자 경험을 향상시키고 인지된 성능(Perceived Performance)을 높이는 강력한 도구이지만, 잘못 구현될 경우 브라우저 렌더링 성능을 심각하게 저하시킬 수 있습니다. 성능 중심의 구현을 위해서는 리플로우(Reflow)와 리페인트(Repaint)를 유발하는 속성의 사용을 피하고, GPU 가속을 활용할 수 있는 `transform`이나 `opacity` 위주로 애니메이션을 작성해야 합니다. 또한, 애니메이션의 지속 시간과 실행 조건을 제어하여 시스템 리소스 소모를 최소화하고 유지보수 가능한 CSS 구조를 만드는 것이 실무적인 핵심입니다.
## 한 줄
> **"매 compositor-only properties + GPU thread + 매 main thread 의 minimal involvement"**. 매 60fps (16.67ms budget) / 120fps (8.33ms) 에서 jank-free 한 animation 의 매 핵심: `transform`/`opacity`/`filter` 만 animate, layout/paint trigger 회피, 매 2026 의 View Transitions API + scroll-driven animations 활용.
## 📖 구조화된 지식 (Synthesized Content)
* **리플로우(Reflow)와 리페인트(Repaint) 최소화**
* `width`, `height`, `margin`, `padding`, `top`, `left` 등 요소의 레이아웃이나 기하학적 형태를 변경하는 속성을 애니메이션하면, 브라우저가 페이지 전체의 구조를 다시 계산하는 리플로우가 발생하여 성능이 크게 저하됩니다 [1-3].
* `box-shadow`, `filter`, `border-radius`와 같은 속성도 브라우저의 렌더링 및 블렌딩 작업에 많은 자원을 요구하여 애니메이션을 느려지게 할 수 있으므로 남용을 피해야 합니다 [1, 4].
* 렌더링 성능을 최적화하려면 리플로우를 일으키지 않는 `transform`(`translate`, `scale` 등)과 `opacity` 속성만을 사용하여 애니메이션을 구현하는 것이 가장 좋습니다 [3-5].
## 매 핵심
* **GPU 가속(Compositing) 적극 활용**
* `transform: translateZ()``rotate3d()` 같은 3D 변환 속성을 적용하거나, 요소가 `position: fixed` 또는 `absolute`일 때 애니메이션을 적용하면 브라우저가 애니메이션 처리를 메인 스레드에서 GPU로 넘깁니다(Compositing). 이는 전체 리플로우를 방지하고 애니메이션을 훨씬 부드럽게 만듭니다 [6-8].
* `will-change` 속성을 사용하여 변경될 요소를 브라우저에 미리 알려 최적화를 유도할 수 있습니다. 단, 과도하게 사용할 경우 오히려 자원을 소모하여 성능 문제를 유발할 수 있으므로 꼭 필요한 곳에만 최후의 수단으로 사용해야 합니다 [6, 9, 10].
### 매 Browser rendering pipeline (2026)
- **JavaScript → Style → Layout → Paint → Composite**.
- **Compositor-only properties** (transform, opacity, filter): Layout/Paint 건너뜀, GPU thread 에서 처리.
- **Layout-trigger** (width, height, top, left, margin): 매 parent + sibling reflow.
- **Paint-trigger** (color, background, box-shadow): GPU upload re-encoded.
* **효율적인 애니메이션 제어 및 리소스 관리**
* 동시에 수백 개의 요소에 애니메이션을 적용하거나, 크고 복잡한 비트맵 배경 이미지를 애니메이션하는 것은 프레임 속도(FPS)를 저하시킵니다. 복잡한 그래픽은 SVG나 CSS 그레이디언트를 사용하는 것이 성능에 유리합니다 [11, 12].
* 무한히 반복되는 애니메이션 루프는 시스템 리소스를 지속적으로 고갈시킵니다. 꼭 필요한 경우가 아니라면 유한한 반복 횟수를 지정하거나, 요소가 화면 밖에 있을 때는 `animation-play-[[State|State]]`를 이용해 애니메이션을 일시 정지시켜야 합니다 [13].
* 애니메이션 지속 시간은 200ms ~ 500ms 사이로 짧게 유지하고, 선형(Linear)보다는 `ease-in-out` 같은 자연스러운 이징(Easing) 함수를 적용하여 빠르고 매끄러운 느낌을 주어야 합니다 [14].
### 매 60fps Budget
- **16.67ms** total — JS work ~5ms, Style+Layout ~3ms, Paint+Composite ~3ms 가 healthy.
- **120fps** (ProMotion, OLED): 8.33ms — 매 strict, native-feel.
- **CrUX threshold**: INP < 200ms (Good).
* **성능 테스트 및 접근성([[Accessibility|Accessibility]]) 고려**
* 애니메이션 코드를 작성한 후에는 반드시 [[Chrome DevTools|Chrome DevTools]]의 [[Performance Panel|Performance Panel]], Layer Profiler 등을 활용해 병목 현상을 파악하고, 저사양 기기에서도 원활히 동작하는지 테스트해야 합니다 [14, 15].
* 전정기관 장애가 있는 사용자는 과도한 움직임에 어지러움을 느낄 수 있으므로, `prefers-reduced-motion` 미디어 쿼리를 활용해 애니메이션을 최소화하거나 끌 수 있는 방안을 마련해야 합니다 [14, 16, 17].
### 매 응용
1. **GPU-accelerated transitions** (route change, modal open).
2. **Scroll-driven animations** (parallax, progress bar) — 매 main thread 떠남.
3. **View Transitions API** — cross-document morph (MPA, SPA route).
## 🔗 지식 연결 (Graph)
- **Related Topics:** 애니메이션 (transition / keyframes), [[실무에서 CSS 관리하는 방법|실무에서 CSS 관리하는 방법]], [[반응형 디자인|반응형 디자인]]
- **Projects/Contexts:** [[실무에서 CSS 관리하는 방법|실무에서 CSS 관리하는 방법]] 관점에서 볼 때, 애니메이션은 "예쁘게" 만드는 것을 넘어 브라우저 렌더링 파이프라인(Layout -> Paint -> Composite)을 이해하고, 저사양 모바일 기기와 시각적 접근성(WCAG 기준)까지 만족시키는 공학적 구현이 동반되어야 합니다.
- **Contradictions/Notes:** `will-change` 속성은 브라우저가 다가올 애니메이션을 대비하도록 하여 성능을 높일 수 있지만, 무분별하게 적용할 경우 과도한 메모리 사용과 최적화 오버헤드로 인해 오히려 렌더링 성능을 악화시킨다는 모순적 특징이 있어 주의가 필요합니다 [9, 10].
## 💻 패턴
---
*Last updated: 2026-04-26*
### Compositor-only animation (CSS)
```css
.card {
transition: transform 200ms cubic-bezier(0.2, 0.8, 0.2, 1),
opacity 200ms ease;
will-change: transform; /* hint — remove after animation */
}
.card:hover {
transform: translateY(-4px) scale(1.02);
}
```
## 🤖 LLM 활용 힌트 (How to Use This Knowledge)
### FLIP technique (animate layout change without layout-trigger)
```typescript
function flip(el: HTMLElement, mutate: () => void) {
const first = el.getBoundingClientRect();
mutate();
const last = el.getBoundingClientRect();
const dx = first.left - last.left;
const dy = first.top - last.top;
const sx = first.width / last.width;
const sy = first.height / last.height;
el.animate(
[{ transform: `translate(${dx}px, ${dy}px) scale(${sx}, ${sy})` }, { transform: 'none' }],
{ duration: 250, easing: 'cubic-bezier(.2,.8,.2,1)' },
);
}
```
**언제 이 지식을 쓰는가:**
- *(TODO)*
### View Transitions API (2026 baseline)
```typescript
// Same-document
async function navigateWithTransition(updateDOM: () => void) {
if (!('startViewTransition' in document)) return updateDOM();
const t = document.startViewTransition(updateDOM);
await t.finished;
}
**언제 쓰면 안 되는가:**
- *(TODO)*
// CSS — name shared elements
.hero { view-transition-name: hero; }
## 🧪 검증 상태 (Validation)
::view-transition-old(hero),
::view-transition-new(hero) {
animation-duration: 400ms;
animation-timing-function: cubic-bezier(.2,.8,.2,1);
}
```
- **정보 상태:** needs_review
- **출처 신뢰도:** A
- **검토 이유:** *(P-Reinforce Phase 1 자동 정규화. 본문 검증 필요.)*
### Scroll-driven animation (CSS only — no JS, off main thread)
```css
@keyframes reveal {
from { opacity: 0; transform: translateY(40px); }
to { opacity: 1; transform: none; }
}
.fade-in {
animation: reveal linear both;
animation-timeline: view();
animation-range: entry 0% cover 30%;
}
```
## 🧬 중복 검사 (Duplicate Check)
### requestAnimationFrame loop with frame budget guard
```typescript
let last = 0;
function tick(now: number) {
const dt = now - last;
last = now;
const start = performance.now();
updatePhysics(dt);
if (performance.now() - start > 8) {
// Defer non-critical to next frame or scheduler.postTask
scheduler.postTask(refreshLowPriorityUI, { priority: 'background' });
}
render();
requestAnimationFrame(tick);
}
requestAnimationFrame(tick);
```
- **기존 유사 문서:** *(TODO: 인덱서 클러스터 리포트 참조)*
- **처리 방식:** UPDATE (자동 정규화)
- **처리 이유:** Phase 1 정규화 — 옛 템플릿/누락 필드 보강.
### Web Animations API — JS-controlled but GPU-eligible
```typescript
const anim = el.animate(
[{ transform: 'translateX(0)' }, { transform: 'translateX(200px)' }],
{ duration: 400, easing: 'ease-out', fill: 'forwards', composite: 'replace' },
);
anim.onfinish = () => el.style.transform = 'translateX(200px)';
```
## ⚠️ 모순 및 업데이트 (Contradictions & Updates)
### Pointer interaction with Pointer Events + passive listener
```typescript
el.addEventListener('pointermove', (e) => {
// No preventDefault — listener can be passive (bypass main thread blocking)
const x = e.clientX, y = e.clientY;
el.style.transform = `translate3d(${x}px, ${y}px, 0)`;
}, { passive: true });
```
- **과거 데이터와의 충돌:** 없음
- **정책 변화:** 없음
### content-visibility for off-screen subtree skip
```css
.lazy-section {
content-visibility: auto;
contain-intrinsic-size: 800px;
}
```
## 🕓 변경 이력 (Changelog)
## 매 결정 기준
| 상황 | Approach |
|---|---|
| Hover/click micro-interaction | CSS transition (transform/opacity) |
| Layout-changing animation | FLIP technique |
| Route/page transition | View Transitions API |
| Scroll-tied progress | scroll-driven CSS (`animation-timeline`) |
| Physics-based (drag, spring) | Web Animations API or framer-motion (with care) |
| Off-main-thread complex | OffscreenCanvas + Worker |
| Large list reveal | content-visibility + IntersectionObserver |
| 날짜 | 변경 내용 | 처리 방식 | 신뢰도 |
|------|-----------|-----------|--------|
| 2026-05-08 | P-Reinforce Phase 1 정규화 (frontmatter + 헤더 표준화) | UPDATE | A |
**기본값**: 매 transform + opacity only. 매 width/height/top/left animate 의 X (rare exception 만). 매 will-change 는 short-lived hint (animate 시작 직전 add, 끝나면 remove).
## 🔗 Graph
- 부모: [[Web-Performance]] · [[Frontend-Performance]] · [[Core-Web-Vitals]]
- 변형: [[CSS-Transitions]] · [[Web-Animations-API]] · [[View-Transitions-API]]
- 응용: [[Scroll-Driven-Animations]] · [[FLIP-Animation-Pattern]] · [[OffscreenCanvas]]
- Adjacent: [[브라우저 메인 스레드 최적화 및 타임 슬라이싱]] · [[INP-Optimization]] · [[GPU-Compositor]]
## 🤖 LLM 활용
**언제**: easing curve 의 candidate generation, FLIP boilerplate, View Transition CSS 의 scaffold.
**언제 X**: 매 perf 측정 — DevTools Performance panel + WebPageTest 만 truth. Jank cause 의 매 nuanced.
## ❌ 안티패턴
- **width/height/top/left animation**: 매 layout-trigger, 매 jank.
- **box-shadow animation**: paint-heavy, blur-radius 변화 의 expensive.
- **`will-change` everywhere**: 매 GPU memory 폭증, 매 reverse effect.
- **JS rAF for what CSS can do**: scroll-driven CSS 가 매 main thread free.
- **Synchronous layout reads in animation loop**: getBoundingClientRect during rAF without batching → forced reflow.
## 🧪 검증 / 중복
- Verified (web.dev/animations 2026, Chrome DevTools Performance docs, View Transitions Level 2 spec, Una Kravets / Bramus Van Damme writings).
- 신뢰도 A.
## 🕓 Changelog
| 날짜 | 변경 |
|---|---|
| 2026-05-08 | Phase 1 |
| 2026-05-10 | Manual cleanup — compositor-only patterns, FLIP, View Transitions, scroll-driven |