첫 페이지(10-20개 항목) 로드 → 로딩 스켈레톤 표시 → 항목 렌더링 → 스크롤 위치 관찰 시작
2
스크롤 감지
사용자 스크롤 추적 → 하단까지 거리 계산 → 트리거 임계값(200-500px) 도달 확인
3
추가 로드 트리거
임계값 도달 → 더 많은 페이지 존재 확인 → 다음 페이지 요청 → 로딩 표시
4
새 항목 추가
데이터 수신 → 기존 리스트에 추가 → 부드러운 페이드인 → 로딩 제거 → 페이지 카운터 업데이트
5
종료 상태
모든 항목 로드 완료 → 로딩 트리거 숨김 → "더 이상 항목 없음" 메시지 → 맨 위로 버튼 표시
인터랙티브 데모
0
로드된 항목
0
페이지
0%
스크롤 진행률
항목을 불러오는 중...
⚠️
로딩 오류
항목을 불러오지 못했습니다
🎉
모든 항목을 확인했습니다
더 이상 표시할 항목이 없습니다
성능 고려사항
가상화 (Virtualization)
긴 리스트의 경우 뷰포트에 보이는 항목만 DOM에 유지하여 성능 최적화
디바운스 스크롤 핸들러
스크롤 이벤트를 디바운스하여 불필요한 계산 방지 (100-200ms)
요청 취소
새 트리거 발생 시 대기 중인 이전 요청 취소하여 중복 방지
캐싱
이전 페이지 데이터를 캐시하여 빠른 앞뒤 탐색 지원
82. 무한 스크롤 시퀀스
Design infinite scroll loading sequence:
**Initial Load**:
- Fetch first page (10-20 items)
- Show loading skeleton
- Render items
- Observe scroll position
**User Scrolls Down**:
- Track scroll position
- Calculate distance to bottom
- Trigger threshold: 200-500px before end
**Load More Trigger**:
- Threshold reached
- Check if more pages exist
- If yes: fetch next page
- Show loading indicator
**Loading Indicator**:
- Spinner at bottom of list
- Or skeleton items
- Or pulsing animation
- Maintain scroll position
**New Items Loaded**:
- Append to existing list
- Smooth height transition
- Remove loading indicator
- Update page counter
**End of Content**:
- All items loaded
- Hide loading trigger
- Show "End of list" message
- Optional: back to top button
**Error During Load**:
- Show error message
- "Retry" button
- Preserve loaded items
- Can continue scrolling up
**Empty Initial State**:
- No items to show
- Empty state illustration
- CTA if applicable
**Refresh Flow** (pull-to-refresh):
- Pull down at top
- Fetch fresh first page
- Replace all items
- Reset pagination
**Performance Considerations**:
- Virtualization for large lists
- Debounce scroll handler
- Cancel pending on new trigger
- Cache previous pages
**Visual Sequence Diagram**:
1. User reaches threshold
2. Request sent
3. Loading shown
4. Response received
5. Items appended
6. Ready for next trigger
Tech: Sequence diagram → react-virtual + Intersection Observer