Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

A ScrollView-like component with parallax and sticky header support.

License

NotificationsYou must be signed in to change notification settings

i6mi6/react-native-parallax-scroll-view

Repository files navigation

NPM

Rodrigocs - Animated Driver

This component now uses Native Driver by default.Remember to pass a Animated component torenderScrollComponent, by default it hasAnimated.ScrollView

Example

importParallaxScrollViewfrom'react-native-parallax-scroll-view';importCustomScrollViewfrom'custom-scroll-view'constAnimatedCustomScrollView=Animated.createAnimatedComponent(CustomScrollView)render(){return(<ParallaxScrollViewbackgroundColor="blue"contentBackgroundColor="pink"parallaxHeaderHeight={300}// renderScrollComponent={() => <Animated.View />}renderScrollComponent={()=><AnimatedCustomScrollView/>}renderForeground={()=>(<Viewstyle={{height:300,flex:1,alignItems:'center',justifyContent:'center'}}><Text>Hello World!</Text></View>)}><Viewstyle={{height:500}}><Text>Scroll me</Text></View></ParallaxScrollView>);}

react-native-parallax-scroll-view

AScrollView-like component that:

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

Installation

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

Note: For React Native 0.19.0 and earlier, you'll want to usereact-native-parallax-scroll-view@0.17.4. Version0.18.0 changes the scrolling API to be compatible with React Native 0.20.0.

Demo

iOSAndroid

Basic Usage

importParallaxScrollViewfrom'react-native-parallax-scroll-view';// Inside of a component's render() method:render(){return(<ParallaxScrollViewbackgroundColor="blue"contentBackgroundColor="pink"parallaxHeaderHeight={300}renderForeground={()=>(<Viewstyle={{height:300,flex:1,alignItems:'center',justifyContent:'center'}}><Text>Hello World!</Text></View>)}><Viewstyle={{height:500}}><Text>Scroll me</Text></View></ParallaxScrollView>);}

Examples

Please refer to theListView example provided to see howParallaxScrollView can be used incombination withListView.

TheAndroid ListView example shows how you can usePullToRefreshViewAndroid withParallaxScrollView.

There are more examples in theexamples folder.

Usage (API)

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

TheParallaxScrollView component adds a few additional properties, as described below.

PropertyTypeRequiredDescription
backgroundColorstringNoThe color of the header background. Defaults to#000)
backgroundScrollSpeednumberNoThe speed factor that the background moves at relative to the foreground. Defaults to 5.
contentBackgroundColorstringNoThis is the background color of the content. (Defaults to'#fff')
fadeOutForegroundboolNoIftrue, the foreground will fade out as the user scrolls up. (Defaults totrue)
onChangeHeaderVisibilityfuncNoA callback function that is invoked when the parallax header is hidden or shown (as the user is scrolling). Function is called with aboolean value to indicate whether header is visible or not.
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 usingbackgroundColor)
renderContentBackgroundfuncNoThis renders the background of the content. Can be used to display cover images for example. (Defaults to a non-visibleView)
renderFixedHeaderfuncNoThis renders an optional fixed header that will always be visible and fixed to the top of the view (and sticky header). You should set its height and width appropriately.
renderForegroundfuncNoThis renders the foreground header that moves at same speed as scroll content.
renderScrollComponentfuncNoA function with inputprops and outputs anAnimated.ScrollView-like component in which the content is rendered. This is useful if you want to provide your own scrollable component, remember however to make it an Animated component. (See:https://github.com/exponentjs/react-native-scrollable-mixin) (By default, returns aAnimated.ScrollView with the given props)
renderStickyHeaderfuncNoThis renders an optional sticky header that will stick to the top of view when parallax header scrolls up.
stickyHeaderHeightnumberIfrenderStickyHeader is usedIfrenderStickyHeader is set, then its height must be specified.
contentContainerStyleobjectNoThese styles will be applied to the scroll view content container which wraps all of the child views. (same as forScrollView)
outputScaleValuenumberNoThe value for the scale interpolation output value, default5
parallaxHeaderContainerStyleobjectNoThese styles will be applied to the parallax header view content container
parallaxHeaderStyleobjectNoThese styles will be applied to the parallax header view content
backgroundImageStyleobjectNoThese styles will be applied to the background image header view content
stickyHeaderStyleobjectNoThese styles will be applied to the sticky headerStyle view content
scrollEventfuncNoCallback to recieve the animated scroll event values

Latest changes

0.20.1

  • Added prop to change interpolated Scale Output Value

0.20.0 // Rodrigocs

  • Now uses native driver, and tested with React Native 0.46.0
  • AddsuseNativeDriver to improve performance, but renderScrollComponent must be a Animated component ( ie: Animated.createAnimatedComponent(component))

See full changeloghere.

Contributing

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

About

A ScrollView-like component with parallax and sticky header support.

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Contributors18


[8]ページ先頭

©2009-2025 Movatter.jp