Socket
Socket
Sign inDemoInstall

react-native-parallax-scroll

Package Overview
Dependencies
0
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    react-native-parallax-scroll

Parallax scroll for React Native


Version published
Maintainers
1
Install size
229 kB
Created

Readme

Source

react-native-parallax-scroll

A ScrollView-like component that:

  • Has a parallax background
  • Has a parallax foreground
  • Has a fixed or sticky header
  • Can be nested within other views
  • Works on iOS and Android

Installation

$ npm install react-native-parallax-scroll --save

Demo

| | | |

Basic Usage

import ParallaxScroll from 'react-native-parallax-scroll';

// Inside of a component's render() method:
render() {
  return (
     <ParallaxScroll
      renderHeader={() => <Header />}
      headerHeight={50}
      isHeaderFixed={false}
      parallaxHeight={250}
      renderParallaxBackground={() => <Background />}
      renderParallaxForeground={() => <Foreground />}
      parallaxBackgroundScrollSpeed={5}
      parallaxForegroundScrollSpeed={2.5}
    >
      <Welcome />
    </ParallaxScroll>
  );
}

Examples

Please clone the repo and run npm run storybook or yarn storybook to show examples of usages.

Usage (API)

All of the properties of ScrollView are supported. Please refer to the ScrollView documentation for more detail.

The ParallaxScroll component adds a few additional properties, as described below.

PropertyTypeDefautDescription
styleobject{}Component's styles
widthnumberDimensions.get('window').widthComponent's width.
heightnumberDimensions.get('window').heightComponent's height.
scrollStyleobject{}These styles will be applied to the scroll view.
headerHeightnumber45This is the height of sticky(fixed) header.
renderHeaderfuncnullThis renders an optional sticky(fixed) header that will be visible to the top of the view.
isHeaderFixedboolfalseIs header fixed to top(not sticky)?
parallaxHeightnumberDimensions.get('window').width * 9 / 16This is the height of parallax.
scrollableComponentclassScrollViewThis is a class of scrollable component.
isBackgroundScalablebooltrueIs background scalable on iOS?
headerBackgroundColorstringrgba(0, 0, 0, 0)The color of the unsticked(unfixed) header background.
contentContainerStyleobject{}These styles will be applied to the scroll view content container which wraps all of the child views.
onChangeHeaderVisibilityfuncnullA callback function that is invoked when the parallax header is hidden or shown (as the user is scrolling). Function is called with a boolean value to indicate whether header is visible or not.
renderParallaxBackgroundfunc() => <View />This renders the background of the parallax.
renderParallaxForegroundfunc() => <View />This renders the foreground of the parallax.
fadeOutParallaxBackgroundboolfalseIf true, the background will fade out as the user scrolls up.
fadeOutParallaxForegroundboolfalseIf true, the foreground will fade out as the user scrolls up.
headerFixedBackgroundColorstringrgba(0, 0, 0, 1)The color of the sticked(fixed) header background.
parallaxBackgroundScrollSpeednumber5The speed factor that the background moves at relative to the scroll content.
parallaxForegroundScrollSpeednumber5The speed factor that the foreground moves at relative to the scroll content.

Contributing

I welcome contributions! Please open an issues if you have any feature ideas or find any bugs. I also accept pull requests with open arms. I will go over the issues when I have time. :)

Keywords

FAQs

Last updated on 12 May 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc