• Stars
    star
    279
  • Rank 147,967 (Top 3 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 7 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

The Parallax ScrollView component we all deserve. 🚀

react-native-parallax-scroll-view


Demo

Demo gif

Installation

This package has a dependency of React Native Elements. Install RNE first with:

yarn add react-native-elements (make sure the version is 0.19.1)

Finally install this package using yarn or npm:

yarn add react-native-parallax-scrollview

Usage

Default Profile Component

import ParallaxScrollView from 'react-native-parallax-scrollview';

<ParallaxScrollView />

Default header view with custom User

<ParallaxScrollView
  windowHeight={SCREEN_HEIGHT * 0.4}
  backgroundSource='http://i.imgur.com/UyjQBkJ.png'
  navBarTitle='John Oliver'
  userName='John Oliver'
  userTitle='Comedian'
  userImage='http://i.imgur.com/RQ1iLOs.jpg'
  leftIcon={{name: 'rocket', color: 'rgba(131, 175, 41, 1)', size: 30, type: 'font-awesome'}}
  rightIcon={{name: 'user', color: 'rgba(193, 193, 193, 1)', size: 30, type: 'font-awesome'}}
/>

Default Header view & Custom ScrollView content

<ParallaxScrollView
  windowHeight={SCREEN_HEIGHT * 0.4}
  backgroundSource='http://i.imgur.com/UyjQBkJ.png'
  navBarTitle='John Oliver'
  userName='John Oliver'
  userTitle='Comedian'
  userImage='http://i.imgur.com/RQ1iLOs.jpg'
  leftIcon={{name: 'rocket', color: 'rgba(193, 193, 193, 1)', size: 30, type: 'font-awesome'}}
  rightIcon={{name: 'user', color: 'rgba(193, 193, 193, 1)', size: 30, type: 'font-awesome'}}
>
  <ScrollView style={{flex: 1, backgroundColor: 'rgba(228, 117, 125, 1)'}}>
    <View style={{height: 300, justifyContent: 'center', alignItems: 'center'}}>
      <Text style={{fontSize: 32, color: 'white'}}>Custom view</Text>
    </View>
    <View style={{height: 300, justifyContent: 'center', alignItems: 'center'}}>
      <Text style={{fontSize: 32, color: 'white'}}>keep going.</Text>
    </View>
    <View style={{height: 300, justifyContent: 'center', alignItems: 'center'}}>
      <Text style={{fontSize: 32, color: 'white'}}>keep going..</Text>
    </View>
    <View style={{height: 300, justifyContent: 'center', alignItems: 'center'}}>
      <Text style={{fontSize: 32, color: 'white'}}>keep going...</Text>
    </View>
    <View style={{height: 300, justifyContent: 'center', alignItems: 'center'}}>
      <Text style={{fontSize: 32, color: 'white'}}>the end! :)</Text>
    </View>
  </ScrollView>
</ParallaxScrollView>

Custom Header view & ScrollView content

<ParallaxScrollView
  windowHeight={SCREEN_HEIGHT}
  backgroundSource='http://i.imgur.com/s4JEY9E.jpg'
  navBarTitle='Custom Title'
  navBarTitleColor='black'
  navBarColor='white'
  headerView={(
    <View style={styles.headerView}>
      <View style={styles.headerTextView}>
        <Text style={styles.headerTextViewTitle}>My App</Text>
        <Text style={styles.headerTextViewSubtitle}>
          Custom Header View
        </Text>
      </View>
    </View>
  )}
  leftIcon={{name: 'rocket', color: 'rgba(228, 117, 125, 1)', size: 30, type: 'font-awesome'}}
  leftIconOnPress={() => this.setState({index: (this.state.index + 1 ) % 3})}
  rightIcon={{name: 'user', color: 'rgba(228, 117, 125, 1)', size: 30, type: 'font-awesome'}}
  rightIconOnPress={() => this.setState({index: (this.state.index + 1 ) % 3})}
>
  <ScrollView style={{flex: 1, backgroundColor: 'rgba(228, 117, 125, 1)'}}>
    <View style={{height: 300, justifyContent: 'center', alignItems: 'center'}}>
      <Text style={{fontSize: 32, color: 'white'}}>Custom view</Text>
    </View>
    <View style={{height: 300, justifyContent: 'center', alignItems: 'center'}}>
      <Text style={{fontSize: 32, color: 'white'}}>keep going.</Text>
    </View>
    <View style={{height: 300, justifyContent: 'center', alignItems: 'center'}}>
      <Text style={{fontSize: 32, color: 'white'}}>keep going..</Text>
    </View>
    <View style={{height: 300, justifyContent: 'center', alignItems: 'center'}}>
      <Text style={{fontSize: 32, color: 'white'}}>keep going...</Text>
    </View>
    <View style={{height: 300, justifyContent: 'center', alignItems: 'center'}}>
      <Text style={{fontSize: 32, color: 'white'}}>the end! :)</Text>
    </View>
  </ScrollView>
</ParallaxScrollView>

API

prop default type description
backgroundSource {uri:http://i.imgur.com/6Iej2c3.png} ImageSourcePropType The background image for the header. The image source is (either a remote URL or a local file resource) backgroundSource={{uri:http://i.imgur.com/6Iej2c3.png}} or backgroundSource={require('./image.png')}
onBackgroundLoadEnd none callback Callback function when the background finishes loading (either with success or failure)
onBackgroundLoadError none callback Callback function when the background loading fails (an object is received with the error details)
windowHeight SCREEN_HEIGHT * 0.5 number The height of the header window
navBarTitle Katy Friedson string The title to be display on the NavBar header
navBarTitleColor 'white' string Color of the navBar title when displayed
navBarColor 'rgba(0, 0, 0, 1.0)' string Color of the navbar when shown
navBarHeight 65 number Height of the navBar when displayed
navBarView Left/Right Icons View custom object Pass in a custom object to override the default navigation bar view
userName Katy Friedson string The user name displayed in the collapsable header view
userImage http://i.imgur.com/uma9OfG.jpg string The user image displayed in the collapsable header view
userTitle Engineering Manager string The user title displayed in the collapsable header view
headerView Profile View custom object Pass in a custom object to override the default header view
leftIcon none object Pass in the left icon name and type as an object. leftIcon={{name: 'rocket', color: 'red', size: 30, type: 'font-awesome'}}
leftIconOnPress none callback Callback function when the left icon is pressed
leftIconUnderlayColor 'transparent' string Underlay color for the left icon.
rightIcon none object Pass in the right icon name and type etc as an object. rightIcon={{name: 'user', color: 'blue', size: 30, type: 'font-awesome'}}
rightIconOnPress none callback Callback function when the right icon is pressed
rightIconUnderlayColor 'transparent' string Underlay color for the right icon.
children List View React Components Render any react views/components as children and these will be rendered below the headerView

Try it out

You can try it out with Exponent here

Example

Look at the example folder to run the expo app locally.

Motivation

Currently there are a couple packages that provide a similar parallax Scrollview component (here and here) although both of them are not maintained and wasn't exactly what I was looking for.

So I challenged myself to create a Parallax ScrollView component (using react-native-parallax-view as a base) with

  1. Sticky NavBar Header 🎉
  2. An awesome default profile component that just works out of the box (<ParallaxScrollView />)
  3. Flexible and comprehensive API to use the ScrollView component for any use case.

aka it's a (Parallax) ScrollView component for React Native that we truly deserve 🚀

Feedback

This repo is being actively manitained. Feel free to open a new Issue with a Feature Request or submit a PR with an Enhancement.

More Repositories

1

react-native-ratings

Tap and Swipe Ratings component for React Native.
TypeScript
862
star
2

react-native-starter

🚀 Starter app for your React Native project using all the latest 💯 & greatest 🏅 components!
JavaScript
84
star
3

react-native-social-starter

React Native Social Starter app - Uses Twitter & Facebook login + Displays User Feed & Profile views
Objective-C
30
star
4

react-native-tinder-cards

Implementing Tinder Card animations in React Native
JavaScript
28
star
5

react-native-graphql-todolist

Todo list app = React Native + Expo + GraphQL + Apollo
JavaScript
17
star
6

Start-Developing-iOS-Apps-Today

This repo provides the perfect starting point for iOS development in Obj-C (and Swift).
Objective-C
12
star
7

Uber-ReactNative

Uber map view with animation built using React Native
JavaScript
9
star
8

HelloWorld-Blockchain

Hello World Dapp in Ethereum with Solidity
JavaScript
4
star
9

Cards-Against-Humanity

Built for CSC 667- Cards against humanity game using Ruby on rails.
Ruby
4
star
10

Asphalt

Functional React Native App; to push the boundaries of my RN skills
JavaScript
4
star
11

xandar

Upload an image and Xandar will predict whether it's a cat or a dog.
JavaScript
4
star
12

portfolio-website

Monte Thakkar - Portfolio Website
JavaScript
3
star
13

reactxp-instagram

Instagram clone built using react-xp. Runs on iOS/Android & Web.
Makefile
3
star
14

todo-list

To-do list app - iOS 11 & Swift 4
Swift
3
star
15

Trump-Quotes-API

Repo that provides Trump Quotes through a simple API.
Ruby
3
star
16

Reddit-ReactNative

Reddit Client app using React Native
Java
3
star
17

parkmerced.live

19th Ave & Karl The Fog - SF Live Stream
CSS
3
star
18

naturexplorer

A website for viewing amazing nature images from various Reddit subs
JavaScript
3
star
19

HelloWorld-Go

Hello world program in Go(lang)
Go
3
star
20

nextjs-tailwindcss-chatgpt-clone

A fully functional clone of ChatGPT website w/ OpenAI API
TypeScript
2
star
21

shitty-instagram

Shitty Instagram close built using React Native
JavaScript
2
star
22

freEDU-Mobile

Mobile App for freEdu: Free Tech Education https://freedu.tech/
JavaScript
2
star
23

Emoji-Artbook

An iOS app for artist to create art with emoji's and images.
Swift
2
star
24

Listenn

Listnn is a iOS app that turns your iPhone into a audio travel guide as you explore the city.
Swift
2
star
25

android-react-native-app

Android app integrated with React Native
Java
2
star
26

MorseCode

Morse Code player for the web
JavaScript
1
star
27

iOS-portfolio-outdated

This is a portfolio of all my work in iOS development.
1
star
28

chantal-app

Chantal - Share stories, anonymously!
JavaScript
1
star
29

pillowcoin

Pillow's own cryptocurrency
JavaScript
1
star
30

portfolio-website-v1

Monte Thakkar - Portfolio website v1
JavaScript
1
star
31

draper

YC Hacks - 2018
JavaScript
1
star
32

TodoApp-Android

Pre-work for Android bootcamp at @Uber x @CodePath
Java
1
star
33

TrumpedOut

Built at Hacktech 2016- Prompt bot wirtten in Node.js + jquery
JavaScript
1
star
34

YelpApp-CodePathU

YelpM is a Yelp search app using the Yelp API.
Swift
1
star
35

SlackTeam-iOSApp

iOS App to view Slack teams
C++
1
star
36

Foto-CodePathU

iOS App for CodePath Demo Day- Converts collection of images into a video for easy sharing.
Objective-C
1
star
37

MovieGuide-ReactNative

Movie Guide app using React Native
JavaScript
1
star
38

nextjs-starter-template

Started template for Next.js + TailwindCSS + NextThemes
JavaScript
1
star
39

react-native-auth

Implementing One Time Password using Text Messages in React Native
HTML
1
star
40

typps

tyypps is a Tip Calculator + Restaurant Logger app for iOS
C++
1
star