# 스크롤 연동 애니메이션 (Scroll-driven animation)

분류: 모션 > 스크롤 효과 (Motion > Scroll effects)
주소: https://ui-glossary-xi.vercel.app/motion/scroll-driven-animation
다른 이름: 스크롤 애니메이션, 스크롤 연동, 스크롤 기반 애니메이션, 스크롤 트리거, 스크롤 진행 표시, scroll-driven animation, scroll driven, scroll-linked animation, scroll timeline, animation-timeline, view timeline, scrollytelling, 스크롤리텔링

시간이 아니라 스크롤한 만큼 진행되는 애니메이션. 애니메이션의 진행을 시간 대신 스크롤 위치에 묶는 방식. 반쯤 내리면 반만, 다시 올리면 거꾸로 돌아간다. CSS에서는 animation-timeline에 scroll()(스크롤 상자 전체의 진행 — 읽기 진행 막대)이나 view()(요소가 화면에 들어와 나가는 구간 — 나타나기·사라지기)을 준다. MDN 호환성 표 기준 크롬·엣지 115, 사파리 26, 파이어폭스 159(2026년 10월)부터 지원해 이제 주요 브라우저 모두 쓸 수 있고, 그 전 판은 @supports로 확인해 정지 상태나 자바스크립트로 대신한다.

| 구분 | 무엇에 묶나 | 흔한 쓰임 |
|---|---|---|
| scroll() | 스크롤 상자의 처음~끝 | 읽기 진행 막대, 헤더 줄어들기, 패럴랙스 |
| view() | 요소가 화면에 들어와 나가는 구간 | 카드 떠오르기, 사진 확대, 글 가리기 풀기 |
| 스크롤 트리거(IntersectionObserver) | 보이는 순간 한 번 — 이후는 시간 | 처음 보일 때 페이드 업 재생 |

## 용도
- 글 읽기 진행 막대, 스크롤에 따라 줄어드는 헤더, 내려가며 단계가 바뀌는 설명(스크롤리텔링).
- 보이는 순간 한 번 재생하면 될 일(카드 페이드 업)은 스크롤 트리거가 더 단순하다 — 연동은 '올리면 되감기'가 필요할 때.
- 스크롤 자체를 가로채거나 늦추지 않는다(스크롤 잠금·강제 스냅 금지). 움직임 줄이기 설정이면 효과를 끄고 끝 상태를 보인다.

## 헷갈릴 수 있는 UI
- 패럴랙스 (Parallax scrolling, https://ui-glossary-xi.vercel.app/md/parallax.md): 패럴랙스는 스크롤 연동으로 만드는 효과 중 하나(배경을 느리게 움직여 깊이감)다. 스크롤 연동 애니메이션은 진행 막대·나타나기 등 스크롤에 묶는 모든 움직임을 말한다.
- 페이드 업 (Fade up, https://ui-glossary-xi.vercel.app/md/fade-up.md): 페이드 업은 효과 이름이다. 보통 보이는 순간 시간으로 한 번 재생하고, 스크롤 연동으로 만들면 스크롤한 만큼만 떠오르고 올리면 도로 내려간다.
- 진행 막대 (Progress bar, https://ui-glossary-xi.vercel.app/md/progress-bar.md): 진행 막대는 작업이 얼마나 됐나 보여 주는 UI다. 글 위에 붙어 '얼마나 읽었나'를 보여 주는 읽기 진행 막대는 스크롤 연동 애니메이션으로 만든다(작업 진행이 아니라 장식에 가깝다).

## AI에게 이렇게 말하세요
- 한국어: 글 상세 페이지 맨 위에 읽기 진행 막대를 스크롤 연동 애니메이션으로 만들어 줘. CSS animation-timeline: scroll(root)로 scaleX 0→1, transform-origin: left. 그리고 본문 사진은 animation-timeline: view()와 animation-range: entry로 화면에 들어오는 동안 아래 24px에서 떠오르게. @supports로 미지원 브라우저는 효과 없이, 움직임 줄이기 설정이면 효과를 끄게.
- English: Build a reading progress bar at the top of the article page as a scroll-driven animation: CSS animation-timeline: scroll(root) animating scaleX 0→1 with transform-origin: left. Also make article images rise 24px into place while entering the viewport using animation-timeline: view() and animation-range: entry. Guard with @supports so unsupported browsers get no effect, and disable it under prefers-reduced-motion.

이렇게 말하면 엉뚱한 게 나와요:
- "스크롤하면 나타나게 해 줘" — 보이는 순간 한 번 재생하는 페이드 업(스크롤 트리거)이 나온다. 스크롤한 만큼 진행·되감기를 원하면 '스크롤 연동(animation-timeline: view())'이라고 말한다. (대신 나오는 것: 페이드 업)
- "읽은 만큼 진행 바" — 작업 진행용 <progress> 요소가 나올 수 있다. '스크롤 위치에 묶인 읽기 진행 막대'라고 말한다. (대신 나오는 것: 진행 막대)

## 핵심 구조 요점
### 태그
- CSS: animation: 이름 linear both; animation-timeline: scroll() 또는 view(); 범위는 animation-range: entry 0% entry 100%처럼. animation-duration은 auto(시간 아님).
- 자바스크립트: el.animate(키프레임, { timeline: new ScrollTimeline({ source }) }) 또는 new ViewTimeline({ subject }).
- 미지원 대안: @supports not (animation-timeline: scroll()) {…} 안에서 정지 상태, 또는 scroll 이벤트로 진행률을 구해 animation.currentTime을 맞춘다.

### 접근성 속성
- 움직이는 장식(진행 막대·배경)은 aria-hidden. 진짜 진행 정보가 필요하면 따로 글로 알린다.
- @media (prefers-reduced-motion: reduce)에서 animation: none — 내용은 끝 상태로 보이게(WCAG 2.3.3).

### 키보드
- 키 조작은 없다. 키보드 스크롤로도 똑같이 진행되고, Tab으로 초점이 간 요소가 아직 투명한 채로 남지 않게 한다.

## 출처
- [MDN — CSS scroll-driven animations](https://developer.mozilla.org/en-US/docs/Web/CSS/Guides/Scroll-driven_animations)
- [MDN — animation-timeline (Browser compatibility)](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/animation-timeline)
- [MDN — ViewTimeline](https://developer.mozilla.org/en-US/docs/Web/API/ViewTimeline)
- [WCAG 2.2 — Understanding 2.3.3 Animation from Interactions](https://www.w3.org/WAI/WCAG22/Understanding/animation-from-interactions.html)
