Socket
Socket
Sign inDemoInstall

@monterosa/react-native-parallax-scroll

Package Overview
Dependencies
0
Maintainers
4
Versions
22
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.6.0 to 1.7.0

6

CHANGELOG.md

@@ -5,2 +5,8 @@ # Changelog

### 1.7.0 - 2018-04-12
#### Added
* `backgroundScale` and `backgroundScaleOrigin` props for support scaling from the top and make scale factor configurable (#22)
### 1.6.0 - 2018-04-05

@@ -7,0 +13,0 @@

2

package.json
{
"name": "@monterosa/react-native-parallax-scroll",
"version": "1.6.0",
"version": "1.7.0",
"description": "Parallax scroll for React Native",

@@ -5,0 +5,0 @@ "repository": {

@@ -61,28 +61,30 @@ [![](https://img.shields.io/npm/dm/@monterosa/react-native-parallax-scroll.svg?style=flat-square)](https://www.npmjs.com/package/@monterosa/react-native-parallax-scroll)

| Property | Type | Defaut | Description |
| ------------------------------- | ------------------------------------------ | ----------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `style` | `object` | `{}` | Component's styles |
| `width` | `number` | `Dimensions.get('window').width` | Component's width. |
| `height` | `number` | `Dimensions.get('window').height` | Component's height. |
| `innerRef` | `func` | `null` | To get a reference to the scrollable component. |
| `scrollStyle` | `object` | `{}` | These styles will be applied to the scroll view. |
| `headerHeight` | `number` | `45` | This is the height of sticky(fixed) header. |
| `renderHeader` | `({ width, height, animatedValue }) => {}` | `null` | This renders an optional sticky(fixed) header that will be visible to the top of the view. |
| `onHeaderFixed` | `func` | `null` | A callback function that is invoked when the header will attach to the top. |
| `isHeaderFixed` | `bool` | `false` | Is header fixed to top(not sticky)? |
| `parallaxHeight` | `number` | `Dimensions.get('window').width * 9 / 16` | This is the height of parallax. |
| `useNativeDriver` | `bool` | `false` | Enable [Native driver](https://facebook.github.io/react-native/blog/2017/02/14/using-native-driver-for-animated.html) for animated. NOTE: Works only with `Animated.ScrollView` component. |
| `scrollableComponent` | `class` | `Animated.ScrollView` | This is a class of scrollable component. |
| `isBackgroundScalable` | `bool` | `true` | Is background scalable on iOS? |
| `headerBackgroundColor` | `string` | `rgba(0, 0, 0, 0)` | The color of the unsticked(unfixed) header background. Can be empty `''` string. NOTE: Dosen't work with useNativeDriver. |
| `contentContainerStyle` | `object` | `{}` | These styles will be applied to the scroll view content container which wraps all of the child views. |
| `headerFixedTransformY` | `number` | `0` | This number indicating how much the fixed header should move upwards during the scroll. Used as the hack to change fixed header height during scroll. |
| `onChangeHeaderVisibility` | `func` | `null` | A 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. |
| `renderParallaxBackground` | `({ width, height, animatedValue }) => {}` | `null` | This renders the background of the parallax. |
| `renderParallaxForeground` | `({ width, height, animatedValue }) => {}` | `null` | This renders the foreground of the parallax. |
| `fadeOutParallaxBackground` | `bool` | `false` | If `true`, the background will fade out as the user scrolls up. |
| `fadeOutParallaxForeground` | `bool` | `false` | If `true`, the foreground will fade out as the user scrolls up. |
| `headerFixedBackgroundColor` | `string` | `rgba(0, 0, 0, 1)` | The color of the sticked(fixed) header background. |
| `parallaxBackgroundScrollSpeed` | `number` | `5` | The speed factor that the background moves at relative to the scroll content. |
| `parallaxForegroundScrollSpeed` | `number` | `5` | The speed factor that the foreground moves at relative to the scroll content. |
| Property | Type | Defaut | Description |
| ------------------------------- | ------------------------------------------ | ----------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `style` | `object` | `{}` | Component's styles |
| `width` | `number` | `Dimensions.get('window').width` | Component's width. |
| `height` | `number` | `Dimensions.get('window').height` | Component's height. |
| `innerRef` | `func` | `null` | To get a reference to the scrollable component. |
| `scrollStyle` | `object` | `{}` | These styles will be applied to the scroll view. |
| `headerHeight` | `number` | `45` | This is the height of sticky(fixed) header. |
| `renderHeader` | `({ width, height, animatedValue }) => {}` | `null` | This renders an optional sticky(fixed) header that will be visible to the top of the view. |
| `onHeaderFixed` | `func` | `null` | A callback function that is invoked when the header will attach to the top. |
| `isHeaderFixed` | `bool` | `false` | Is header fixed to top(not sticky)? |
| `parallaxHeight` | `number` | `Dimensions.get('window').width * 9 / 16` | This is the height of parallax. |
| `useNativeDriver` | `bool` | `false` | Enable [Native driver](https://facebook.github.io/react-native/blog/2017/02/14/using-native-driver-for-animated.html) for animated. NOTE: Works only with `Animated.ScrollView` component. |
| `scrollableComponent` | `class` | `Animated.ScrollView` | This is a class of scrollable component. |
| `isBackgroundScalable` | `bool` | `true` | Is background scalable on iOS? |
| `headerBackgroundColor` | `string` | `rgba(0, 0, 0, 0)` | The color of the unsticked(unfixed) header background. Can be empty `''` string. NOTE: Dosen't work with useNativeDriver. |
| `contentContainerStyle` | `object` | `{}` | These styles will be applied to the scroll view content container which wraps all of the child views. |
| `headerFixedTransformY` | `number` | `0` | This number indicating how much the fixed header should move upwards during the scroll. Used as the hack to change fixed header height during scroll. |
| `onChangeHeaderVisibility` | `func` | `null` | A 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. |
| `renderParallaxBackground` | `({ width, height, animatedValue }) => {}` | `null` | This renders the background of the parallax. |
| `renderParallaxForeground` | `({ width, height, animatedValue }) => {}` | `null` | This renders the foreground of the parallax. |
| `fadeOutParallaxBackground` | `bool` | `false` | If `true`, the background will fade out as the user scrolls up. |
| `fadeOutParallaxForeground` | `bool` | `false` | If `true`, the foreground will fade out as the user scrolls up. |
| `headerFixedBackgroundColor` | `string` | `rgba(0, 0, 0, 1)` | The color of the sticked(fixed) header background. |
| `backgroundScale` | `number` | `3` | The speed factor that the background scales. Respects `backgroundScaleOrigin` |
| `backgroundScaleOrigin` | `center | top` | `center` | The point of which the background should scroll from. Use `top` with `backgroundScale={2}` in order to achieve iOS native parallax scroll behavior. Top will keep the background locked to the top of the scrollview, while scaling the image such that it stretches the background in the downwards direction. |
| `parallaxBackgroundScrollSpeed` | `number` | `5` | The speed factor that the background moves at relative to the scroll content. |
| `parallaxForegroundScrollSpeed` | `number` | `5` | The speed factor that the foreground moves at relative to the scroll content. |

@@ -93,2 +95,8 @@ ## Latest changelog

### 1.7.0 - 2018-04-12
#### Added
* `backgroundScale` and `backgroundScaleOrigin` props for support scaling from the top and make scale factor configurable (#22)
### 1.6.0 - 2018-04-05

@@ -106,8 +114,2 @@

### 1.5.3 - 2018-02-14
#### Fixed
* issues #17, #18 - fatal error when `scrollableComponent` prop is missing
## Contributing

@@ -114,0 +116,0 @@

@@ -32,4 +32,6 @@ /* eslint-disable import/no-extraneous-dependencies */

useNativeDriver: PropTypes.bool,
backgroundScale: PropTypes.number,
scrollableComponent: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
isBackgroundScalable: PropTypes.bool,
backgroundScaleOrigin: PropTypes.oneOf(['top', 'center']),
headerFixedTransformY: PropTypes.number,

@@ -70,5 +72,7 @@ headerBackgroundColor: PropTypes.string,

parallaxHeight: window.width * RATIO,
backgroundScale: 3,
useNativeDriver: false,
scrollableComponent: Animated.ScrollView,
isBackgroundScalable: true,
backgroundScaleOrigin: 'center',
headerFixedTransformY: 0,

@@ -193,14 +197,20 @@ headerBackgroundColor: 'rgba(0, 0, 0, 0)',

fadeOutParallaxBackground,
parallaxBackgroundScrollSpeed
parallaxBackgroundScrollSpeed,
backgroundScale,
backgroundScaleOrigin
} = this.props;
/* eslint-disable indent */
const topOrigin = backgroundScaleOrigin === 'top';
const translateY = !height
? 0
: this.scrollY.interpolate({
inputRange: [0, height],
outputRange: [0, -(height / parallaxBackgroundScrollSpeed)],
extrapolateRight: 'extend',
extrapolateLeft: 'clamp'
});
inputRange: [...(topOrigin ? [-height, 0] : [0]), height],
outputRange: [
...(topOrigin ? [-(height / backgroundScale) + height, 0] : [0]),
-(height / parallaxBackgroundScrollSpeed)
],
extrapolateLeft: 'extend',
extrapolateRight: 'extend'
});

@@ -211,7 +221,7 @@ const scale =

: this.scrollY.interpolate({
inputRange: [-height, 0],
outputRange: [3, 1],
extrapolateLeft: 'extend',
extrapolateRight: 'clamp'
});
inputRange: [-height, 0],
outputRange: [backgroundScale, 1],
extrapolateLeft: 'extend',
extrapolateRight: 'clamp'
});

@@ -222,7 +232,6 @@ const opacity =

: this.scrollY.interpolate({
inputRange: [0, height],
outputRange: [1, 0],
extrapolate: 'clamp'
});
/* eslint-enable indent */
inputRange: [0, height],
outputRange: [1, 0],
extrapolate: 'clamp'
});

@@ -229,0 +238,0 @@ return (

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