3.5.1 • Published 3 days ago

react-native-reanimated-carousel v3.5.1

Weekly downloads
-
License
MIT
Repository
github
Last release
3 days ago

English | 简体中文

react-native-reanimated-carousel

platforms npm npm github issues github closed issues

Click on the image to see the demo. 🍺

ReactNative community's best use of the carousel component! 🎉🎉🎉

  • It completely solves this problem for react-native-snap-carousel! More styles and apis in development... Try it
  • SimpleInfinitely scrolling very smoothFully implemented using Reanimated 2!

Reason


Installation

Open a Terminal in the project root and run:

yarn add react-native-reanimated-carousel

Or if you use npm:

npm install react-native-reanimated-carousel

Now we need to install react-native-gesture-handler and react-native-reanimated(>=2.0.0).

EXPO

If use EXPO managed workflow please ensure that the version is greater than 41.Because the old version not support Reanimated(v2)

Usage

import Carousel from 'react-native-reanimated-carousel';

<Carousel<{ color: string }>
    width={width}
    data={[{ color: 'red' }, { color: 'purple' }, { color: 'yellow' }]}
    renderItem={({ color }) => {
        return <View style={{ backgroundColor: color, flex: 1 }} />;
    }}
/>;

Optimizing

  • When rendering a large number of elements, you can use the 'windowSize' property to control how many items of the current element are rendered. The default is full rendering. After testing without this property, frames will drop when rendering 200 empty views. After setting this property, rendering 1000 empty views is still smooth. (The specific number depends on the phone model tested)

Props

namerequireddefaulttypesdescription
dataT[]Carousel items data set
widthnumberSpecified carousel container width
renderItem(data: T, index: number) => React.ReactNodeRender carousel item
defaultIndex0numberDefault index
autoPlayfalsebooleanAuto play
autoPlayReversefalsebooleanAuto play reverse playback
autoPlayInterval1000autoPlayIntervalAuto play playback interval
modedefalut'default'|'stack'|'parallax'Carousel Animated transitions
looptruebooleanCarousel loop playback
parallaxScrollingOffset100numberWhen use 'parallax' Layout props,this prop can be control prev/next item offset
parallaxScrollingScale0.8numberWhen use 'parallax' Layout props,this prop can be control prev/next item scale
style{}ViewStyleCarousel container style
height'100%'undefined | string | numberSpecified carousel container height
onSnapToItem(index: number) => voidCallback fired when navigating to an item
onScrollBegin() => voidCallback fired when scroll begin
onScrollEnd(previous: number, current: number) => voidCallback fired when scroll end
panGestureHandlerProps{}Omit<Partial\<PanGestureHandlerProps>,'onHandlerStateChange'>PanGestureHandler props
windowSize0numberThe maximum number of items that can respond to pan gesture events, 0 means all items will respond to pan gesture events
onProgressChangeonProgressChange?: (offsetProgress: number,absoluteProgress: number) => voidOn progress change. offsetProgress:Total of offset distance (0 390 780 ...); absoluteProgress:Convert to index (0 1 2 ...)
verticalfalsebooleanLayout items vertically instead of horizontally
animationConfig{ mode: 'vertical',snapDirection: 'left',moveSize: window.width,stackInterval: 30,scaleInterval: 0.08,rotateZDeg: 135}{mode: 'vertical' | 'horizontal';moveSize?: number;stackInterval?: number;scaleInterval?: number;rotateZDeg?: number;snapDirection?: 'left' | 'right';}Stack layout animation style
showLengthdata.length - 1numberThe maximum number of items will show in stack
pagingEnabledtruebooleanWhen true, the scroll view stops on multiples of the scroll view's size when scrolling
enableSnaptruebooleanIf enabled, releasing the touch will scroll to the nearest item, valid when pagingEnabled=false

Ref

nametypesdescription
prev()=>voidPlay the last one
loop()=>voidPlay the next one
goToIndex(index: number, animated?: boolean) => voidGo to index
getCurrentIndex()=>numberGet current item index

Example

yarn example -- ios
yarn example -- android

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT

4.0.0-alpha.12

3 days ago

4.0.0-alpha.11

4 days ago

4.0.0-alpha.10

2 months ago

4.0.0-alpha.9

4 months ago

4.0.0-alpha.8

5 months ago

4.0.0-alpha.7

5 months ago

4.0.0-alpha.6

5 months ago

4.0.0-alpha.5

5 months ago

4.0.0-alpha.3

5 months ago

4.0.0-alpha.4

5 months ago

4.0.0-alpha.1

5 months ago

4.0.0-alpha.2

5 months ago

4.0.0-alpha.0

10 months ago

3.4.0

11 months ago

3.5.1

10 months ago

3.5.0

10 months ago

3.2.0

1 year ago

3.3.1

1 year ago

3.3.0

1 year ago

3.3.2

1 year ago

3.1.3

2 years ago

3.1.2

2 years ago

3.1.1

2 years ago

3.1.0

2 years ago

3.1.5

2 years ago

3.1.4

2 years ago

3.0.6

2 years ago

3.0.5

2 years ago

2.4.0

2 years ago

2.6.0

2 years ago

3.0.4

2 years ago

3.0.3

2 years ago

3.0.2

2 years ago

3.0.1

2 years ago

3.0.0

2 years ago

2.5.0

2 years ago

2.5.1

2 years ago

2.3.8

2 years ago

2.3.7

2 years ago

2.3.9

2 years ago

2.3.6

2 years ago

2.3.5

2 years ago

2.3.11

2 years ago

2.3.10

2 years ago

2.3.3-beta.0

2 years ago

2.3.4

2 years ago

2.3.3

2 years ago

2.3.3-beta.1

2 years ago

2.3.2-beta.0

2 years ago

2.3.2-beta.1

2 years ago

2.3.2

2 years ago

2.3.1

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

2.2.1

2 years ago

2.2.0

2 years ago

2.2.3

2 years ago

2.2.2

2 years ago

2.2.4

2 years ago

1.2.0-beta.1

2 years ago

1.2.0-beta.0

2 years ago

1.2.0-beta.3

2 years ago

1.2.0-beta.2

2 years ago

1.2.0-beta.4

2 years ago

2.0.0

2 years ago

2.2.5-beta.0

2 years ago

2.2.5-beta.1

2 years ago

2.2.5-beta.2

2 years ago

2.2.5-beta.3

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

2.3.0

2 years ago

2.1.2

2 years ago

2.1.1

2 years ago

2.1.0

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.12

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

3 years ago

0.5.3-beta.0

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago

0.5.4

3 years ago

0.5.3

3 years ago

0.5.0

3 years ago

0.5.2

3 years ago

0.5.1

3 years ago

0.4.5

3 years ago

0.4.4

3 years ago

0.4.3

3 years ago

0.4.2

3 years ago

0.3.0

3 years ago

0.4.1

3 years ago

0.4.0

3 years ago

0.3.1

3 years ago

0.2.2

3 years ago

0.2.1

3 years ago

0.2.0

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago