Skip to main content

ParallaxScrollView

A scroll view component with parallax scrolling effects, providing smooth animations as content is scrolled.

Installation

import { ParallaxScrollView } from "@/core/components/ParallaxScrollView";

Basic Usage

import React from "react";
import { ParallaxScrollView } from "@/core/components/ParallaxScrollView";

export default function ParallaxScrollViewExample() {
return (
<ParallaxScrollView
headerBackgroundColor="#f0f0f0"
headerImage={<Image source={{ uri: "https://example.com/header.jpg" }} />}
>
<Text>Your scrollable content goes here</Text>
<Text>Content moves with parallax effect</Text>
</ParallaxScrollView>
);
}

Props

PropTypeDefaultDescription
headerImageReactElement-Header image or component to display with parallax effect
headerBackgroundColorstring-Background color for the header section
headerHeightnumber250Height of the parallax header
parallaxRationumber0.5Ratio of parallax scrolling effect (0-1)
childrenReactNode-Required. Scrollable content
contentContainerStyleStyleProp<ViewStyle>-Styles for the content container
styleStyleProp<ViewStyle>-Additional styles for the scroll view

Usage Examples

With Header Image

<ParallaxScrollView
headerImage={
<Image
source={{ uri: "https://example.com/beautiful-landscape.jpg" }}
style={{ width: "100%", height: "100%" }}
/>
}
headerBackgroundColor="#4a90e2"
>
<View style={{ padding: 16 }}>
<Text>Your content here...</Text>
</View>
</ParallaxScrollView>

Custom Parallax Effect

<ParallaxScrollView
headerImage={<YourCustomHeaderComponent />}
headerBackgroundColor="#ff6b6b"
headerHeight={300}
parallaxRatio={0.3}
>
<YourContent />
</ParallaxScrollView>

With Themed Colors

<ParallaxScrollView
headerImage={<GradientBackground />}
headerBackgroundColor={theme.colors.primary}
contentContainerStyle={{ backgroundColor: theme.colors.background }}
>
<ThemedText>Themed parallax content</ThemedText>
</ParallaxScrollView>

Performance Considerations

  • The parallax effect uses native animations for smooth performance
  • Header images should be optimized for mobile devices
  • Consider using lower resolution images for better performance on slower devices

Accessibility

  • Supports scroll accessibility features
  • Header content can include accessible elements
  • Maintains proper focus management during scrolling