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

react-native-viewpager-carousel

Package Overview
Dependencies
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-viewpager-carousel

[![npm version](https://badge.fury.io/js/react-native-viewpager-carousel.svg)](https://badge.fury.io/js/react-native-viewpager-carousel) [![dependencie status](https://david-dm.org/meinto/react-native-viewpager-carousel.svg)](https://david-dm.org/meinto/r

  • 0.3.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

npm version dependencie status dev-dependency status npm npm travis build

Contribution

Feel free to make a pull request. I'm happy about every contribution.

Examples

You can find example implementations for all use cases of this library in the repo react-native-viewpager-carousel-example-app. The example project is also linked as git submodule in this project.

Installation

yarn add react-native-viewpager-carousel

or

npm install --save react-native-viewpager-carousel

Preview

preview

ViewPager

The <ViewPager /> is the base component of the library. Till now it acts like a simple view-carousel:

import { ViewPager } from 'react-native-viewpager-carousel'

class ExampleCarousel extends PureComponent {

    constructor() {
        this.data = [
            { title: 'title 1' },
            { title: 'title 2' },
            { title: 'title 3' },
        ]
    }
    
    _renderPage = ({data}) => {
        return ( <Text>{item.title}</Text> )
    }

    render() {
        return (
            <ViewPager
                data={this.data}
                renderPage={this._renderPage}
            />
        )
    }
}

API

prop namedata typedefaultfunctionality
containerStylestyle{}the component is wrapped into a <View />. Styles to this <View /> can be assigned through this property
contentContainerStylestyle{}posibility to set styles to the content container (the entire scrollable area)
dataarray[]a data array of objects
devbooleanfalsedraws a black line around the pages and tabs for debugging
lazyrenderbooleanfalselazyrender renders the active page only when its in the viewport
lazyrenderThresholdnumber1determines how many threshold left and right the current visible page sould be rendered if lazyrender={true}
renderAsCarouselbooleantruerenders the as endless carousel
thresholdPagesnumber1number of pages left and right of the scrollable content (sneak preview)
pageWidthnumber{{screen width of device}}width of page
initialPageobject{}key value pair of initial page: e. g. data=[{key:'page-a'}, {key:'page-b'}] & initialPage={{key:'page-b}}
scrollEnabledbooleantruedecleares wether the ViewPager sould be able to scroll by user or not
firePageChangeIfPassedScreenCenterbooleanfalsetoggle's if onPageChange sould already be called when the dragged page passed half of the screen
pageingEnabledbooleantrue
experimentalMirroringbooleanfalsetoggles the mirroring of the scrollposition of the threshold views - more information here
showNativeScrollIndicatorbooleanfalsenative ScrollView indicator is disabled by default
renderPagefunction() => {}render callback for content page
onPageChangefunction() => {}callback when the page changes -> retuns the current pageNumber as first argument
onScrollfunction() => {}callback when the content area scrolls

TabbedPager

In addition to the <ViewPager /> the <TabbedPager /> component provides an additional renderFunction for Tabs above the content view. The following pseudo-code shows the basic usage with an <Image /> as content and a <Text /> as tab.

import { TabbedPager } from 'react-native-viewpager-carousel'

class ExampleCarousel extends PureComponent {

    constructor() {
        this.data = [
            { title: 'title 1', url: 'http://...' },
            { title: 'title 2', url: 'http://...' },
            { title: 'title 3', url: 'http://...' },
        ]
    }
    
    _renderTab = ({data}) => {
        return ( <Text>{data.title}</Text> )
    }
    
    _renderPage = ({data}) => {
        return ( <Image source={{uri: data.url}} /> )
    }

    render() {
        return (
            <ViewPager
                data={this.data}
                renderTab={this._renderTab}
                renderPage={this._renderPage}
            />
        )
    }
}

API

prop namedata typedefaultfunctionality
dataarray[]a data array of objects
devbooleanfalsedraws a black line around the pages and tabs for debugging
fullScreenbooleantruedraws the in full screen mode (flex 1)
lazyrenderbooleanfalselazyrender renders the active page only when its in the viewport
lazyrenderThresholdnumber1determines how many threshold left and right the current visible page sould be rendered if lazyrender={true}
renderAsCarouselbooleantruerenders the as endless carousel
tabContainerPositionstring'top'could be 'top' || 'bottom' - places the tab container on top of the viewpager or on the bottom side
scrollTabsEnabledbooleanfalse
firePageChangeIfPassedScreenCenterbooleanfalsetoggle's if onPageChange sould already be called when the dragged page passed half of the screen
staticTabWidthnumber{{screen width of device / 2}}
initialPageobject{}key value pair of initial page: e. g. data=[{key:'page-a'}, {key:'page-b'}] & initialPage={{key:'page-b}}
showTabIndicatorbooleantruetoggles the tab indicator
tabIndicatorColorstring'transparent'changes the color of the tab indicator
tabIndicatorHeightnumber2height of tab indicator
tabsVisiblebooleantrueindicates if tabs should be visible or not
DividerComponentanynullrenders a given Component between the tabs and the content area
renderPagefunction() => {}render callback for content page
renderTabfunction() => {}render callback for the tab
onPageChangefunction() => {}callback when the page changes -> retuns the current pageNumber as first argument
experimentalMirroringbooleanfalsetoggles the mirroring of the scrollposition of the threshold views - more information here

Keywords

FAQs

Package last updated on 27 Jan 2019

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