npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-swiper-parallax

v0.1.0

Published

swiper with a parallax effect for react native

Downloads

15

Readme

Swiper parallax

react-native-swiper-parallax is a swiper component for React Native featuring paging and an optional parallax effect. Compatible with Android & iOS.

Getting started

npm install react-native-swiper-parallax --save

Usage

Content and delayed content are being passed as render props.

import Slider from 'react-native-swiper-parallax';

class MyComponent extends Component {
  renderContent = content => {
    return (
      <Content>
        <Text>content</Text>
      </Content>
    );
  };

  renderDelayedContent = content => {
    return (
      <DelayedContent>
        <Text>{content.title}</Text>
      </DelayedContent>
    );
  };

  render() {
    return (
      <Slider
        slides={slides}
        renderContent={this.renderContent}
        renderDelayedContent={this.renderDelayedContent}
        delayFactor={0.3}
        triggeringThreshold={0}>
        {(slideCount, currentIndex, nextIndex, requestSlideIndex) => (
          <Fragment>
            <PagingContainer>
              <Paging
                slideCount={slideCount}
                currentSlideIndex={currentIndex}
                currentControlColor={colors.mainOrange}
                defaultControlColor="rgba(46, 43, 43, 0.25)"
              />
            </PagingContainer>

            <BottomBar
              swipe={() => requestSlideIndex(currentIndex, currentIndex + 1)}
            />
          </Fragment>
        )}
      </Slider>
    );
  }
}

In depth

The Slider component is using React context api. It has a provider and every child which uses the HOC withSliderContext has access to the Slider store which is shown below.

const SliderContext = createContext({
  currentIndex: null,
  nextIndex: null,
  setCurrentIndex: () => {},
  setNextIndex: () => {},
  slideCount: null,
});

The Slider itself is inside the provider and has therefore access to an action which sets the next index before the animation is triggered. The Paging component while being connected to the Slider store is aware of any index change in real time. Slider has a shouldComponentUpdate method which prevents the component from re rendering when the nextIndex is set:

shouldComponentUpdate(nextProps: OwnProps) {
		return this.props.nextIndex === nextProps.nextIndex;
}

Props

| Props | Params | Returns | Description | | :------------------- | :------------------------: | :-----: | :---------------------------------------------------- | | slides | content delayedContent | none | Array of slides with a content and a delayed content | | renderContent | content | jsx | Render all slides main content | | renderDelayedContent | content | jsx | Render all slides delayed content for parallax effect | | delayFactor | none | none | Number to delay the sliding animation |

OwnProps (withSliderContext HOC)

| OwnProps | Params | Returns | Description | | :-------------- | :-----: | :-----: | :---------------------------------------------- | | currentIndex | none | none | Slider current index | | nextIndex | none | none | Slider next index before animation is triggered | | setCurrentIndex | index | none | Set current index | | setNextIndex | index | none | Set next index | | slideCount | none | none | Number of slides |