Giter VIP home page Giter VIP logo

andreialecu / react-native-reanimated-carousel Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dohooo/react-native-reanimated-carousel

1.0 1.0 0.0 299.1 MB

Simple React Native carousel component,fully implemented using reanimated v2,support to iOS/Android/Web.(轮播图、swiper)

License: MIT License

JavaScript 4.31% Ruby 0.66% C++ 3.60% Objective-C 1.24% Java 7.90% TypeScript 79.30% Objective-C++ 1.88% Makefile 0.79% Starlark 0.31%

react-native-reanimated-carousel's Introduction

English | 简体中文

react-native-reanimated-carousel

platforms npm npm npm github issues github closed issues discord chat

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

  • It completely solves this [problem] for react-native-snap-carousel!
  • SimpleInfinitely scrolling very smoothFully implemented using Reanimated 2!

V2 has been released! Join it! [v1 docs]

Support to Web [demo]

Click on the image to see the code snippets. [Try it] 🍺

normal-horizontal normal-vertical parallax-horizontal
parallax-vertical stack-horizontal-left stack-horizontal-right
stack-vertical-left stack-vertical-right stack-horizontal-right

Now you can make cool animations with us! Very easy! [Details]

advanced-parallax pause-advanced-parallax scale-fade-in-out
rotate-scale-fade-in-out rotate-in-out anim-tab-bar
marquee multiple circular
parallax-layers flow fold

Table of contents

  1. Installation
  2. Usage
  3. Props
  4. Tips
  5. Reason
  6. Example

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).

react-native-reanimated react-native-gesture-handler
react-native-reanimated-carousel < v3 <2.7.0 *
react-native-reanimated-carousel >= v3 >=2.7.0 *

Usage

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

<Carousel
    width={300}
    height={150}
    data={[1, 2, 3]}
    renderItem={({ item }) => <AnyElement />}
/>;

Tips

  • 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)
  • Used in ScrollView/FlastList

    • #143 - Carousel suppresses ScrollView/FlastList scroll gesture handler: When using a carousel with a layout oriented to only one direction (vertical/horizontal) and inside a ScrollView/FlatList, it is important for the user experience that the unused axis does not impede the scroll of the list. So that, for example, the x-axis is free we can change the activeOffsetX of the gesture handler:

      <Carousel
        {...}
        panGestureHandlerProps={{
          activeOffsetX: [-10, 10],
        }}
      />
  • RTL

    • Support to RTL mode with no more configuration needed. But in RTL mode, need to manually set the autoPlayReverse props for autoplay to control scrolling direction.
  • EXPO

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

Reason

The common RN infinite scroll component. It get stuck on a fast slide. Wait for the next element to appear. This component will not have similar problems.Because using a completely different approach so the best performance is achieved.That's why this library was created.

Use react-native-snap-carousel for quick swiping,you can see caton clearly when you reach the junction.(gif 4.6mb)

Compared with react-native-reanimated-carousel,The actual test was ten slides per second, but it didn't show up very well in gif.

Example

:pretty use pretty images

yarn ios
yarn ios:pretty

yarn android
yarn android:pretty

yarn web
yarn web:pretty

Sponsors

License

MIT

react-native-reanimated-carousel's People

Contributors

berdyshev avatar braandl avatar dohooo avatar gxxgcn avatar kusstar avatar leviwilliams avatar tristanfrantz avatar wilav-dev avatar yepmad avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.