0.1.1 • Published 10 months ago

react-native-roller v0.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

react-native-roller

React Native component for rolling things.

NPM version Downloads

Installation

Supported version: react-native >= 0.68.0

yarn add react-native-roller

or

npm i react-native-roller

Example

Scroll texts in a loop, one row at a time

import Roller from 'react-native-roller'

<Roller
  dataSource={[
    '1 - While there is life, there is hope',
    '2 - Do what you say,say what you do',
    '3 - All things come to those who wait',
    '4 - Nothing seek, nothing find'
  ]}
  style={styles.bg}
/>

npm.io

Display 3 rows in the visible area

<Roller
  dataSource={[
    '1 - While there is life, there is hope',
    '2 - Do what you say,say what you do',
    '3 - All things come to those who wait',
    '4 - Nothing seek, nothing find'
  ]}
  itemStyle={styles.bg}
  visibleRowsNum={3}
  spaceBetween={6}
/>

npm.io

Enable the visible offset

<Roller
  dataSource={[
    '1 - While there is life, there is hope',
    '2 - Do what you say,say what you do',
    '3 - All things come to those who wait',
    '4 - Nothing seek, nothing find'
  ]}
  itemStyle={styles.bg}
  visibleRowsNum={3}
  spaceBetween={6}
  enableVisibleOffset
/>

npm.io

bg styles:

{
  backgroundColor: 'rgba(0, 0, 0, 0.5)',
  borderRadius: 4,
  paddingHorizontal: 9,
}

API

proptypedefault valuedescription
dataSourceany[]DataSource array for rows
visibleRowsNumnumber1Number of rows visible
rowHeightnumber30Height per row
spaceBetweennumber0Space between rows
intervalnumber3000Interval between two rolling
animationDurationnumber600Duration of each rolling animation (milliseconds)
fadeOutDurationnumber600Duration of the fade-out animation for the first row
fadeInDurationnumber600Duration of the fade-in animation for the last row
styleStyleProp<ViewStyle>Container style
itemStyleStyleProp<ViewStyle>Item style
textStyleStyleProp<TextStyle>Text style
shouldRollboolean \| ((rowsLen: number, visibleRowsNum: number) => boolean)trueWhether to roll
forceRollbooleantrueWhether to roll when the number of dataSource is insufficient
enableVisibleOffsetbooleanfalseWhether to enable the visible offset

License

MIT, see the LICENSE file for detail.

0.1.1

10 months ago

0.1.0

10 months ago