All Projects → r0b0t3d → react-native-carousel

r0b0t3d / react-native-carousel

Licence: MIT License
React Native carousel

Programming Languages

typescript
32286 projects
java
68154 projects - #9 most used programming language
objective c
16641 projects - #2 most used programming language
javascript
184084 projects - #8 most used programming language
ruby
36898 projects - #4 most used programming language
c
50402 projects - #5 most used programming language
swift
15916 projects

Projects that are alternatives of or similar to react-native-carousel

infinite-carousel-flutter
Carousel in flutter. Supports infinite looping and gives control over anchor and velocity.
Stars: ✭ 24 (-31.43%)
Mutual labels:  infinite-scroll, carousel
React Native Snap Carousel
Swiper/carousel component for React Native featuring previews, multiple layouts, parallax images, performant handling of huge numbers of items, and more. Compatible with Android & iOS.
Stars: ✭ 9,151 (+26045.71%)
Mutual labels:  infinite-scroll, carousel
react-cool-virtual
😎 ♻️ A tiny React hook for rendering large datasets like a breeze.
Stars: ✭ 1,031 (+2845.71%)
Mutual labels:  infinite-scroll, carousel
react-native-reanimated-carousel
🎠 React Native swiper/carousel component, fully implemented using reanimated v2, support to iOS/Android/Web. (Swiper/Carousel)
Stars: ✭ 1,461 (+4074.29%)
Mutual labels:  infinite-scroll, carousel
InfiniteCarousel
💈Infinite Carousel Collection View
Stars: ✭ 67 (+91.43%)
Mutual labels:  infinite-scroll, carousel
react-gallery-carousel
Mobile-friendly gallery carousel 🎠 with server side rendering, lazy loading, fullscreen, thumbnails, touch, mouse emulation, RTL, keyboard navigation and customisations.
Stars: ✭ 178 (+408.57%)
Mutual labels:  carousel
ngx-carousel
Angular Universal carousel is an lightweight , touchable and responsive library
Stars: ✭ 14 (-60%)
Mutual labels:  carousel
shopify-product-image-slider
Implementation of the Slick image carousel into a Shopify store
Stars: ✭ 21 (-40%)
Mutual labels:  carousel
ui
JavaScript UI component library, includes the latest Fancybox
Stars: ✭ 222 (+534.29%)
Mutual labels:  carousel
react-tabllist
React-based customizable style table or list components that support event and callback functions.
Stars: ✭ 20 (-42.86%)
Mutual labels:  infinite-scroll
Pageable
An easy way to Pagination or Infinite scrolling for TableView/CollectionView
Stars: ✭ 44 (+25.71%)
Mutual labels:  infinite-scroll
Perky
Perky a beautiful animated app concept built with lots of love in React Native.
Stars: ✭ 37 (+5.71%)
Mutual labels:  reanimated2
nglp-angular-material-landing-page
NGLP is an Angular Material Landing Page.
Stars: ✭ 32 (-8.57%)
Mutual labels:  carousel
react-native-bidirectional-infinite-scroll
📜 React Native - Bidirectional Infinite Smooth Scroll
Stars: ✭ 137 (+291.43%)
Mutual labels:  infinite-scroll
react-simple-infinite-loading
A list that infinitely loads content as user scrolls down in React
Stars: ✭ 56 (+60%)
Mutual labels:  infinite-scroll
vue-virtual-scroll-grid
A Vue 3 component that can render a list with 1000+ items as a grid in a performant way.
Stars: ✭ 64 (+82.86%)
Mutual labels:  infinite-scroll
ACarousel
A carousel view for SwiftUI | SwiftUI 旋转木马效果
Stars: ✭ 124 (+254.29%)
Mutual labels:  carousel
Endless
🛣 A lightweight endless pageControl based on CAShapeLayers and UICollectionView
Stars: ✭ 19 (-45.71%)
Mutual labels:  infinite-scroll
reanimated2Animations
Practicing with reanimated 2 animations
Stars: ✭ 21 (-40%)
Mutual labels:  reanimated2
react-native-animated-carousel
🦄 A wonderful animated carsouel hooks component for React-Native
Stars: ✭ 16 (-54.29%)
Mutual labels:  carousel

react-native-carousel

Hits

alt text

Getting started

$ yarn add @r0b0t3d/react-native-carousel

Note: Currently, I am using react-native-reanimated for animation. So you should install it as well

$ yarn add react-native-reanimated

Breaking changes

v3.4.0

Added:

  • You have to wrap your component inside withCarouselContext
  • useCarouselContext hook

Removed:

  • Remove component's ref

Changed:

  • Methods goNext, goPrev, snapToItem now accessible via useCarouselContext
const {
    goNext,
    goPrev,
    snapToItem
  } = useCarouselContext();
Other versions

v3.3.0

  • Changed: renderItem now required and add more props to easy customization
renderItem: (
  data: { item: T; index?: number },
  animatedData?: { scrollPosition?: Animated.SharedValue<number>, offset?: number }
) => React.ReactNode

v3.0.0

  • Added:
    • animatedPage: animated value used which is current selected page. Used to pass into the PaginationIndicator for animation.
  • Removed:
    • useIndicator, indicatorContainerStyle, renderIndicator, . Used PaginationIndicator instead
    • renderOverlay: you can render overlay inside renderItem function
  • Changed:
    • renderImage -> renderItem

v2.0.0

Show cases

Loop Scale Alignment
alt text alt text alt text

Loop

<Carousel
  loop={true}
  autoPlay={true}
  duration={3000}
  animation="parallax"
/>

Scale

<Carousel
  itemWidth={width - 100}
  inactiveOpacity={0.5}
  inactiveScale={0.9}
/>

Alignment

<Carousel
  itemWidth={width - 100}
  inactiveOpacity={0.5}
  inactiveScale={0.9}
  firstItemAlignment="start"
/>

Usage

import Carousel, {
  withCarouselContext,
  useCarouselContext,
} from '@r0b0t3d/react-native-carousel';

function MyCarousel() {
  const {
    goNext,
    goPrev,
    snapToItem
  } = useCarouselContext(); // <- use this instead of passing ref to Carousel

  return (
    <View>
      <Carousel
        style={{ height: 200 }}
        data={data}
        loop={false}
        autoPlay={true}
        duration={3000}
        itemWidth={width - 100}
        inactiveOpacity={0.5}
        inactiveScale={0.9}
        firstItemAlignment="start"
        spaceBetween={20}
        animatedPage={currentPage}
        renderItem={({item}) => {
          return (
            <Image
              style={{
                flex: 1,
                backgroundColor: 'red',
              }}
              source={{ uri: item.url }}
            />
          );
        }}
      />
      <View>
        <PaginationIndicator
          containerStyle={{ marginTop: 20 }}
          activeIndicatorStyle={{
            height: 10,
            borderRadius: 5,
          }}
          indicatorConfigs={{
            spaceBetween: 10,
            indicatorWidth: 10,
            indicatorSelectedWidth: 20,
          }}
        />
      </View>
    </View>
  );
}

export default withCarouselContext(MyCarousel) // <-- To use carousel context, you need wrap your component with withCarouselContext

Carousel

Properties

Props Description Default
data Array of item to be rendered.
- id: string: this will be used as key to render
- source: ImageSourcePropType: optional. Image source. If you don't want to pass source here. You could use renderItem below to render your custom image.
------
Or it could be array of string
loop? Whether your carousel can loop or not false
initialPage? Set the first page show up 0
additionalPagesPerSide? When looping, how many page will be added at head and tail to perform loop effect 2
autoPlay? Auto animate to next image with duration. false
duration? Duration to animate. used with autoPlay above 1000
animation? Predefined animation. Will be parallax for now
sliderWidth? Define slider width screen's width
itemWidth? Define item width screen's width
firstItemAlignment? `'center' 'start'`
Align first item
inactiveOpacity? [0 - 1] Define opacity for inactive items 1
inactiveScale? [0 - 1] define scale value for inactive items 1
spaceBetween? Add additional space between items 0
spaceHeadTail? Add more space in head/tail. This only work if firstItemAlignment = 'start' 0
animatedPage? Animated value which is the current page. This value used to pass into PaginationIndicator for animation
renderItem (data: { item: T; index?: number }, animatedData?: { scrollPosition?: Animated.SharedValue<number>, offset?: number }) => React.ReactNode
Render carousel item
onPageChange? (index: number) => void
Callback to notify when page change

Methods

Method Description
goNext Go to next index
goPrev Go to previous index
snapToItem (index: number, animated?: boolean) => void
Snap to specific index
- index: destination index
- animated: should animate or not, default is true

withCarouselContext

This HOC provides easy way to wrap your component with CarouselContext.Provider. So if you'd like to use useCarouselContext, you need to wrap your component with this.

PaginationIndicator

Easy way to define the indicator for your carousel.

Please note that, this component only works with withCarouselContext. So please make sure that it is rendered under the component that you wrap with withCarouselContext

Check example above for more info

Contributing

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

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].