Git Product home page Git Product logo

react-native-parallax-scrollview's Introduction

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.

react-native-parallax-scrollview's People

Contributors

aiss17 avatar avishayil avatar iroachie avatar monte9 avatar nak1b avatar raouldandresy avatar reyhansofian avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-native-parallax-scrollview's Issues

remove header icon

in my case, I don't need the header icons. I've tried to remove the leftIcon and rightIcon from props, but it seems that this library have a default value if props not present

Didn't work on android platform?

I tried to replace a ScrollView with ParallaxScrollView , but it performed the same way with ScrollView, I couldn't pull the head view any higher when I was trying to. So, what may the problem be? Is there any necessary property I forgot ?

How to change the font-size of navbar title?

Hi, i am using this module it's working fine. How can i change the font-size of navbar title in parallax-scrollview. Please give me any suggestion. Thank you in advance.

Code:-

<ParallaxScrollView
          windowHeight={height * 0.5}
          backgroundSource={{
            uri: imageArray
              ? productDetails.images[0]
              : productDetails.images,
          }}
          navBarTitle={productDetails.product.title}
          navBarTitleColor={Colors.white}
          navBarColor={Colors.black}
          headerView={<View style={{flex: 1}} />}
          leftIcon={{
            name: 'chevron-left',
            color: Colors.white,
            size: 20,
            type: 'font-awesome',
          }}
          leftIconOnPress={() => navigation.pop()}>
          <Scrollview>{this.renderContent()}</Scrollview>
        </ParallaxScrollView>

Versions:-

"react-native": "0.61.4"
"react-native-parallax-scrollview": "^3.0.0"

Color Changing Header

When i scroll, the header changes color as though it's animated alongside the scroll?

Oddly, this only happens if i use RGBA / Hex codes or rarely used 'wordcolors' like 'deepskyblue' in the navBarColor prop

If i just set it as 'black' or ' blue' etc then it just stays solid (this is the behaviour i'd want and expect given the lack of prop to turn off animated changing colours in the header )

screen shot 2019-03-08 at 09 32 18
screen shot 2019-03-08 at 09 32 28
screen shot 2019-03-08 at 09 32 36
screen shot 2019-03-08 at 09 32 47

implements Error

As I implement the examples, it shows Error by 'Argument 0 (UIStatusBarStyle) of StatusBarManager. must not be null'...

please give me a advice

Thanks

Expo and React native issues

Hi,

I am reaching you to ask if there is an Expo compatible problem or something similar with your library. I inserted you library as shown in the README for it to work, and suddenly, I get this error:
image

The moment I press the profile go to button, that error comes up and my app stops working. It is not an Expo or Recat-Native problem because all the other views are fine, it is just the profile when I stick this code:

<ParallaxScrollView
        windowHeight={SCREEN_HEIGHT * 0.4}
        backgroundSource='../assets/images/profile_background_2.png'
        navBarTitle='Profile'
        userName={user.displayName}
        userTitle='+34 660 20 92 91'
        userImage= {user.photoURL}
      />

If you have a solution it would be awesome, if not, is there anything you could do to fix it?

Thank you very much

Properties of my app:
"dependencies": {
"expo": "^32.0.6",
"react": "^16.8.6",
"react-native": "https://github.com/expo/react-native/archive/sdk-32.0.0.tar.gz",
"react-native-elements": "^1.1.0",
"react-native-parallax-scrollview": "^3.0.0",
"react-navigation": "^3.0.9"
}

Add image Slider in background

Hi, First thank you,
i want to put a image Slide like Background, but yout background is juste imageSource ?
any Help ?
Thank you

Compatibility issues with react 16

Since react 16.0.0 released, many things changed 😞 and your nice project became incompatible with that.
Would you please update repo to matches new changes? πŸ˜ƒ

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.