Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-native-parallax-swiper

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-parallax-swiper

Full Screen Parallax Swiper Allowing Arbitrary UI Injection

  • 0.5.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
30
increased by66.67%
Maintainers
1
Weekly downloads
 
Created
Source

React Native Parallax Swiper

npm npm styled with prettier

Configurable parallax swiper based on an iOS pattern.

Features

  • Flexible. Pass your own Animated.Value and use that value for both ParallaxSwiper and your own UI.
  • Performant. Leverages useNativeDriver for 60FPS and no latency.
  • Cross-platform. Implement your parallax on both iOS and Android.

Twitter Moments Demo
Vevo Demo
Lightbox Demo

Installation

$ yarn add react-native-parallax-swiper

Usage

import ParallaxSwiper from 'react-native-parallax-swiper';
constructor() {
  super();
  
  this.myCustomAnimatedValue = new Animated.Value(0);
}
<ParallaxSwiper
  parallaxStrength={80}
  animatedScrollValue={this.myCustomAnimatedValue}
  dividerWidth={8}
  dividerColor="black"
  backgroundColor="#fff"
  onMomentumScrollEnd={activePageIndex => console.log(activePageIndex)}
>
  <Animated.View
    style={{
      flex: 1,
      alignItems: "center",
      justifyContent: "center",
      opacity: this.myCustomAnimatedValue.interpolate({
        inputRange: [0, deviceWidth * 0.25],
        outputRange: [1, 0]
      })
    }}
    backgroundImage={`https://source.unsplash.com/user/erondu/${deviceHeight + 1}x${deviceWidth + 1}`}
  >
    <Text>Parallaxing is rad</Text>
  </Animated.View>
  <View
    style={{
      flex: 1,
      alignItems: "center",
      justifyContent: "center"
    }}
    backgroundImage={`https://source.unsplash.com/user/erondu/${deviceHeight}x${deviceWidth}`}
  >
    <Text>Parallaxing is too rad</Text>
  </View>
</ParallaxSwiper>

Props

PropTypeDefaultDescription
parallaxStrengthNumber80This number determines how slow parallax’ing element moves. Lower number yields a subtler parallax effect, higher number increases parallax effect.
dividerWidthNumber8The width of the divider between each page. (horizontal only)
dividerColorStringblackColor of divider.
backgroundImageStringN/AThe image source. If used this becomes the background image that parallaxes. (remote URL only for now)
backgroundImageResizeModeStringcoverDetermines how to resize the image.
backgroundColorStringblackThe main view’s background color.
scrollToIndexFunction0Scrolls to index with a smooth animation. If used onComponentDidMount scroll is immediate with no animation.
onMomentumScrollEndFunctionN/ACalled when ScrollView stops scrolling and is passed the current page index.
animatedScrollValueAnimated.Value0Optionally pass a new instance of Animated.Value to this prop to have access to the animated scroll value to animate your own components.
childrenReactComponentsN/AJSX to inject into the page.
verticalBooleanfalseWhen true, ParallaxSwiper’s children are arranged vertically in a column instead of horizontally in a row. For now only iOS supports this, but there is work to implement vertical paging on Android.
showsHorizontalScrollIndicatorBooleanfalseWhen true, shows a horizontal scroll indicator. The default value is false.
showsVerticalScrollIndicatorBooleanfalseWhen true, shows a vertical scroll indicator. The default value is false.

TODO

  • Create Expo demos
  • Create examples
  • Expose current index
  • Support scrollToIndex
  • Fix Android
  • Expose Animated.Value for animation outside of ParallaxSwiper
  • Add drag effects e.g. zoom, blur, darken
  • Expose rest of ScrollView props

Why another parallax component? 😒

This component is inspired by an iOS pattern that no react-native-parallax-whatever previously delivered. It emulates this pattern by using the ScrollView component which has features like velocity, paging, and platform specific easing curves; It also has optional dividers to split up each page. You can see this pattern in apps like iOS Camera Roll, Twitter Moments, Kylie Jenner’s app, Vevo’s app, and more.

Contributors


Chris LeBlanc

[💻]

Questions or suggestions?

Hit me up on Twitter, or create an issue.

Copyright (c) 2017 Zachary Gibson Licensed under the MIT license.

Keywords

FAQs

Package last updated on 15 Sep 2017

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