0.1.10 • Published 5 years ago

react-native-da-slider v0.1.10

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

react-native-da-slider

This component does not relly on other libs besides react-native.

The component uses nothing but react-native and PropTypes.

Contributing

Despite this is not a elaborated component, every contributing is very welcomed.

If you find using the component and having some problem, please file one ISSUE

If you think that you can improve the component, please open one PR

Instalation

yarn add react-native-da-slider

Usage

Basic

The slider will take the space of the parent container and the slider pages, will have diferent heights. No autoplay, loop or any customization.

<Slider
  pages={[
    () => <View style={{ backgroundColor: 'red', flex: 1 }}>
      <Text>Open up App.js to start working on your app!</Text>
    </View>
    ,
    () => <View style={{ backgroundColor: 'blue', height: 100 }}>
      <Text>Open up App.js to start working on your app!</Text>
    </View>
    ,
    () => <View style={{ backgroundColor: 'red', flex: 0.5 }}>
      <Text>Open up App.js to start working on your app!</Text>
    </View>
    ,
    () => <View style={{ backgroundColor: 'blue', height: 100 }}>
      <Text>Open up App.js to start working on your app!</Text>
    </View>
    ,
    () => <View style={{ backgroundColor: 'red', height: 100, }}>
      <Text>Open up App.js to start working on your app!</Text>
    </View>
    ,
    () => <View style={{ backgroundColor: 'blue', height: 100 }}>
      <Text>Open up App.js to start working on your app!</Text>
    </View>
  ]}
  >
</Slider>

With some features

<Slider
  loop
  autoplay
  height={100}
  autoplayInterval={2000}
  defaultPaginationActiveColor="black"
  defaultPaginationInactiveColor="blue"
  pages={[
    () => <View style={{ backgroundColor: 'red', height: 100, }}>
      <Text>Open up App.js to start working on your app!</Text>
    </View>
    ,
    () => <View style={{ backgroundColor: 'blue', height: 100 }}>
      <Text>Open up App.js to start working on your app!</Text>
    </View>
    ,
    () => <View style={{ backgroundColor: 'red', height: 100, }}>
      <Text>Open up App.js to start working on your app!</Text>
    </View>
    ,
    () => <View style={{ backgroundColor: 'blue', height: 100 }}>
      <Text>Open up App.js to start working on your app!</Text>
    </View>
    ,
    () => <View style={{ backgroundColor: 'red', height: 100, }}>
      <Text>Open up App.js to start working on your app!</Text>
    </View>
    ,
    () => <View style={{ backgroundColor: 'blue', height: 100 }}>
      <Text>Open up App.js to start working on your app!</Text>
    </View>
  ]}
>
</Slider>

Structure

  • example - This folder has one usage example with expo. You can do yarn start.
  • Slider - The component that you will use

Props

PropDefaultTypeDescription
pagesisRequiredarrayOne array of function, where each function returns the page to be rendered by the splider
overridePaginationfalse'bool'One boolean indicating if the component default pagination will be rendered
renderCustomPagination() => {'function'This callback allows you to add custom element to the default pagination element
autoplayfalseboolOne boolean to indicate if the slider is on autoplay mode or not
autoplayInterval2000numberThe number of milliseconds between each autoplay loop.
loopfalse'bool'Indicates if the component should allow to loop. Go from last index to the first and oposite
onIndexChange() => {}'function'One callback that will be called each time the index of sliding page has already changed.
heightundefinednumberThis props lets you specify the height of the slider. The default will lead to flex meaning it will default to the slider container sizes. Use height to set slider container size
defaultPaginationActiveColorblack'stringThis string is the color to be used on the active page dot, when default pagination is not overriden
defaultPaginationInactiveColorwhite'stringThis string is the color to be used on the inactive page dot, when default pagination is not overriden

TODO

  • Extract to multiple components
  • Write unit tests
0.1.10

5 years ago

0.1.9

5 years ago

0.1.8

5 years ago

0.1.7

5 years ago

0.1.6

5 years ago

0.1.5

5 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago