React Native Scroll Progress Animation ๐
Wednesday, December 28, 2022
demos
scroll-progress
An ongoing collection of React Native animations crafted with Reanimated, Gesture Handler, and Skia.
TypeScript
3.2k
296
A scrollable content list with animated progress tracking.
What's This About?
This component creates a sophisticated scrollable content interface with a progress indicator. It tracks reading progress through sections of content, calculates estimated reading time, and provides smooth scroll animations. The implementation includes precise scroll position tracking, progress calculations, and a reset functionality, making it perfect for long-form content or article readers.
Technical Implementation
The component uses:
Scroll position tracking
Reading time calculation
Progress indicators
Reset functionality
Layout measurements
Usage
// Data structure
type Section = {
title: string;
description: string;
};
// Basic usage
<ScrollProgress />
// Section list with custom rendering
<SectionContentList
sections={sections}
renderSection={(section, index) => (
<View key={index}>
<Text>{section.title}</Text>
<Text>{section.description}</Text>
</View>
)}
contentContainerStyle={{
paddingHorizontal: 20,
paddingTop: 20,
paddingBottom: 100
}}
/>
// Progress calculation
const scrollableHeight = useDerivedValue(() => {
return scrollHeight.value - viewHeight.value + paddingBottom;
});
const progress = clamp(
scrollOffset / scrollableHeight,
0,
1
);
Unlock the beauty of React Native animations
Learn Reanimated, Gesture Handler & Skia with Reanimate.dev
Feedback on Scroll Progress
Ideas, bugs, or anything that felt off: I read every message. For anything else, write to hello@reactiive.io.
Send feedback