Wheel Picker with Reanimated and Gesture Handler
Wednesday, April 24, 2024
demos
wheel-picker
An ongoing collection of React Native animations crafted with Reanimated, Gesture Handler, and Skia.
TypeScript
3.2k
296
A customizable wheel picker with animated count display and draggable slider.
What's This About?
This component creates an interactive wheel picker with an animated number display and a draggable slider. It features expandable line spacing, smooth animations, and precise value selection. The implementation includes a customizable slider with gradient boundaries, animated count display, and responsive layout, making it perfect for numeric value selection or any interface requiring precise control over numerical values.
Technical Implementation
The component uses:
Animated counting
Draggable slider
Space animation
Progress tracking
Gradient boundaries
Usage
// Basic usage
<WheelPicker />
// Animated count display
<AnimatedCount
count={animatedNumber}
maxDigits={10}
textDigitWidth={44}
textDigitHeight={80}
fontSize={65}
/>
// Draggable slider
<DraggableSlider
scrollableAreaHeight={150}
spacePerLine={animatedSpacePerLine}
showBoundaryGradient
bigLineIndexOffset={20}
snapEach={1}
linesAmount={50}
maxLineHeight={20}
minLineHeight={10}
onProgressChange={(progress) => {
'worklet';
if (progress < 0) return;
animatedValue.value = progress;
}}
/>
// Space animation
const animatedSpacePerLine = useDerivedValue(() => {
return withTiming(isExpanded ? 50 : 20);
}, [isExpanded]);
// Progress tracking
const progress = useSharedValue(0);
const animatedNumber = useDerivedValue(() => {
const multiplier = 1;
return Math.ceil(
progress.value * LinesAmount * multiplier
);
}, [progress]);
Unlock the beauty of React Native animations
Learn Reanimated, Gesture Handler & Skia with Reanimate.dev
Feedback on Wheel Picker
Ideas, bugs, or anything that felt off: I read every message. For anything else, write to hello@reactiive.io.
Send feedback