File tree Expand file tree Collapse file tree 3 files changed +36
-0
lines changed
img/react-transition-group Expand file tree Collapse file tree 3 files changed +36
-0
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ title : React Transition Group
3+ createdAt :
4+ category :
5+ description :
6+ ---
7+
8+ ::: warning
9+ 아직 작성중이거나 검토중인 글입니다. 내용이 부정확하거나 변경될 수 있습니다
10+ :::
11+
12+ ## 서론
13+
14+ 디자인학과 졸업전시 웹사이트 프젝 진행 중
15+
16+ 전체 페이지에 수평 아코디언 애니메이션을 넣으려고
17+ 처음엔 모든 페이지를 한 번에 마운트해서 max-width로 접음
18+ 근데 Lighthouse에서 DOM 요소 3,495개 경고 뜨고
19+ TBT 높고 메모리 사용량도 계속 늘어남
20+ 언마운트 ?
21+
22+ ## 문제 접근방법
23+
24+ React Transition Group으로 상태 전이에 따라 in=true/false로 애니메이션 시도
25+ 컴포넌트마다 enter/exit 애니메이션 끝나면 자동으로 언마운트 되도록 처리
26+ switch transition도 고려했지만, 여러 페이지를 동시에 다뤄야 해서 transitionGroup 선택
27+ CSS로 transform 기반 애니메이션 구현해서 reflow/repaint 최소화
28+
29+ ## 해결방법
30+
31+ ` <TransitionGroup><CSSTransition> ` 구조로 전환 흐름 제어
32+
33+ 전환 시 DOM에 둘 다 남겨두고, 퇴장 페이지는 exit 애니메이션 후 DOM에서 제거
34+ 새 페이지는 enter > entered 상태로 자연스럽게 등장
35+ css transform: translateX()로 GPU 가속 유도
36+ timeout 또는 transitionend 로 애니메이션 완료 감지 -> ,언마운트
You can’t perform that action at this time.
0 commit comments