0.3.0 • Published 2 years ago

@wecraftapps/react-native-simple-carousel v0.3.0

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

react-native-simple-carousel

Package to render a simple carousel with React Native. Works on Android and iOS.

Showcase

Basic usage for fullscreen slides

react-native-simple-carousel

example component for basic usage

Basic usage for card layout

react-native-simple-carousel

example component for basic usage card layout

Installation

npm i --save @wecraftapps/react-native-simple-carousel

Basic usage

import { SimpleCarousel } from '@wecraftapps/react-native-simple-carousel';

...

const carouselRef = useRef(null);

...

return (
  <SimpleCarousel ref={carouselRef}>
    <View style={{ width: '100%', height: '100%', justifyContent: 'center', alignItems: 'center', backgroundColor: 'yellow'}}>
      <Text>PAGE 0</Text>
    </View>

    <View style={{ width: '100%', height: '100%', justifyContent: 'center', alignItems: 'center', backgroundColor: 'green'}}>
      <Text>PAGE 1</Text>
    </View>
  </SimpleCarousel>
);

Props

PropTypeOptionnalDescriptionDefault
setIndexfunctiontruefunction to be called to update the current page indexnull
layoutCAROUSEL_LAYOUTStruestring that indicates the type of layout the carousel will have (see the Types section for details)FULLSCREEN
cardLayoutOptionsCardLayoutOptionstrueobject describing the carousel layout using layout = 'CARD' (see the Types section for details)null
scrollEnabledbooleantrueboolean that indicates if the carousel can be scrolledtrue
initialSlidenumbertrueinitial slide index0

Methods

Following methods are available using a ref

NameArgumentsDescription
previousPagefunction to navigate to the previous slide if possible
nextPagefunction to navigate to the next slide if possible

Types

enum CAROUSEL_LAYOUTS {
  FULLSCREEN = 'FULLSCREEN',
  CARD = 'CARD',
}
interface CardLayoutOptions {
  offset: number, // horizontal space to see the adjacent cards. Default is 40,
  adjacentCardsScale: number, // scale of the adjacent cards. Default is 0.85,
  adjacentCardsOpacity: number, // default is 0.5,
}

Special thanks

Special thanks to @chanonroy for tutorial : https://chanonroy.medium.com/building-a-netflix-style-card-carousel-in-react-native-649afcd8d78e

0.3.0

2 years ago

0.2.1

2 years ago

0.2.6

2 years ago

0.2.3

2 years ago

0.2.2

2 years ago

0.2.5

2 years ago

0.2.4

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago