Fancy Color Carousel with Reanimated and Skia ๐
Wednesday, May 17, 2023
demos
color-carousel
An ongoing collection of React Native animations crafted with Reanimated, Gesture Handler, and Skia.
TypeScript
3.2k
296
A visually stunning carousel that combines smooth item transitions with dynamic radial gradient backgrounds. Features a responsive design that adapts the background color based on the active item.
What's This About?
This component creates an interactive carousel where each item transition is accompanied by a smooth color transformation in the background. The radial gradient background dynamically changes to match the active item's accent color, creating a cohesive and engaging visual experience.
Technical Implementation
The component leverages Skia for high-performance rendering and implements:
Smooth carousel transitions
Dynamic radial gradient backgrounds
Configurable number of visible items
Optimized rendering with a fixed number of items
Shared value animations for color transitions
Usage
type CarouselItem = {
accentColor: string;
// other item properties
};
// Basic usage
<ColorCarousel />
// Custom implementation
<Carousel
items={data}
maxRenderedItems={5} // Must be an odd number
width={windowWidth}
activeIndex={activeIndex}
/>
// With background gradient
<Canvas style={StyleSheet.absoluteFill}>
<Rect x={0} y={0} width={width} height={height}>
<RadialGradient
c={vec(width/2, height/2)}
r={width/2}
colors={colors}
/>
</Rect>
</Canvas>
Unlock the beauty of React Native animations
Learn Reanimated, Gesture Handler & Skia with Reanimate.dev
Feedback on Color Carousel
Ideas, bugs, or anything that felt off: I read every message. For anything else, write to hello@reactiive.io.
Send feedback