Socket
Socket
Sign inDemoInstall

react-native-parallax-scroll-view

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-parallax-scroll-view

A ScrollView-like component with parallax and sticky header support


Version published
Weekly downloads
2.4K
increased by9.8%
Maintainers
1
Weekly downloads
 
Created
Source

react-native-parallax-scroll-view

A ScrollView-like component that:

  • Has a parallax header
  • Has an optional sticky header
  • Is composable with any component that expects a ScrollView (e.g. ListView or InfiniteScrollView)
  • Can be nested within other views
  • Works on iOS and Android

(Tested with react-native 0.16.0 on Android and iOS.

Installation

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

Demo

iOSAndroid

Basic Usage

import ParallaxScrollView from 'react-native-parallax-scroll-view';

// Inside of a component's render() method:
render() {
  return (
    <ParallaxScrollView
      backgroundColor="blue"
      contentBackgroundColor="pink"
      parallaxHeaderHeight={300}
      renderParallaxHeader={() => (
       <View style={{ height: 300, flex: 1, alignItems: 'center', justifyContent: 'center' }}>
          <Text>Hello World!</Text>
        </View>
      )}>
      <View style={{ height: 500 }}>
        <Text>Scroll me</Text>
      </View>
    </ParallaxScrollView>
  );
}

Examples

Please refer to the ListView example provided to see how ParallaxScrollView can be used in combination with ListView.

The Android ListView example shows how you can use PullToRefreshViewAndroid with ParallaxScrollView.

There are more examples in the examples folder.

Usage (API)

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

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

PropertyTypeRequiredDescription
parallaxHeaderHeightnumberYesThis is the height of parallax header.
renderBackgroundfuncNoThis renders the background of the parallax header. Can be used to display cover images for example. (Defaults to an opaque background using backgroundColor)
backgroundSpeednumberNoThe speed factor that the background moves at relative to the foreground. Defaults to 5.
renderForegroundfuncNoThis renders the foreground header that moves at same speed as scroll content.
renderStickyHeaderfuncNoThis renders an optional sticky header that will stick to the top of view when parallax header scrolls up.
stickyHeaderHeightnumberIf renderStickyHeader is usedIf renderStickyHeader is set, then its height must be specified.
renderFixedHeaderfuncNoThis renders an optional fixed header that will always be visible and fixed to the top of the view (and sticky header). You must set its height and width appropriately.
renderScrollComponentfuncNoA function with input props and outputs a ScrollView-like component in which the content is rendered. This is useful if you want to provide your own scrollable component. (See: https://github.com/exponentjs/react-native-scrollable-mixin) (By default, returns a ScrollView with the given props)
contentBackgroundColorstringNoThis is the background color of the content. (Defaults to '#fff')
onChangeHeaderVisibilityfuncNoA 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.

Changelog

0.17.0

  • Refactored parallax header calculations to keep their scroll speeds consistent with user scroll speed.
  • Parallax effect is now calculated using the backgroundSpeed prop.

Keywords

FAQs

Package last updated on 02 Feb 2016

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc