🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

react-native-reanimated-carousel

Package Overview
Dependencies
Maintainers
0
Versions
118
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-reanimated-carousel

Simple carousel component.fully implemented using Reanimated 2.Infinitely scrolling, very smooth.

4.0.2
latest
Source
npm
Version published
Weekly downloads
226K
-1.51%
Maintainers
0
Weekly downloads
 
Created

What is react-native-reanimated-carousel?

react-native-reanimated-carousel is a highly customizable and performant carousel component for React Native, leveraging the power of Reanimated 2 for smooth animations.

What are react-native-reanimated-carousel's main functionalities?

Basic Carousel

This code demonstrates a basic carousel with three items. The carousel is rendered using the `react-native-reanimated-carousel` package, and each item is displayed within a styled container.

import React from 'react';
import { View, Text, StyleSheet } from 'react-native';
import Carousel from 'react-native-reanimated-carousel';

const data = ['Item 1', 'Item 2', 'Item 3'];

const BasicCarousel = () => {
  return (
    <Carousel
      width={300}
      height={200}
      data={data}
      renderItem={({ item }) => (
        <View style={styles.itemContainer}>
          <Text>{item}</Text>
        </View>
      )}
    />
  );
};

const styles = StyleSheet.create({
  itemContainer: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#fff',
    borderRadius: 8,
    shadowColor: '#000',
    shadowOffset: { width: 0, height: 2 },
    shadowOpacity: 0.8,
    shadowRadius: 2,
    elevation: 1,
  },
});

export default BasicCarousel;

Custom Animation

This code demonstrates a carousel with custom animations. The `customAnimation` prop is used to define a custom animation for the carousel items, and the `animationConfig` prop is used to configure the animation's easing and duration.

import React from 'react';
import { View, Text, StyleSheet } from 'react-native';
import Carousel from 'react-native-reanimated-carousel';
import { Easing } from 'react-native-reanimated';

const data = ['Item 1', 'Item 2', 'Item 3'];

const CustomAnimationCarousel = () => {
  return (
    <Carousel
      width={300}
      height={200}
      data={data}
      renderItem={({ item }) => (
        <View style={styles.itemContainer}>
          <Text>{item}</Text>
        </View>
      )}
      customAnimation={(value) => ({
        transform: [{ scale: value }],
        opacity: value,
      })}
      animationConfig={{
        easing: Easing.inOut(Easing.ease),
        duration: 500,
      }}
    />
  );
};

const styles = StyleSheet.create({
  itemContainer: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#fff',
    borderRadius: 8,
    shadowColor: '#000',
    shadowOffset: { width: 0, height: 2 },
    shadowOpacity: 0.8,
    shadowRadius: 2,
    elevation: 1,
  },
});

export default CustomAnimationCarousel;

Looping Carousel

This code demonstrates a looping carousel. The `loop` prop is set to true, which makes the carousel items loop infinitely.

import React from 'react';
import { View, Text, StyleSheet } from 'react-native';
import Carousel from 'react-native-reanimated-carousel';

const data = ['Item 1', 'Item 2', 'Item 3'];

const LoopingCarousel = () => {
  return (
    <Carousel
      width={300}
      height={200}
      data={data}
      renderItem={({ item }) => (
        <View style={styles.itemContainer}>
          <Text>{item}</Text>
        </View>
      )}
      loop
    />
  );
};

const styles = StyleSheet.create({
  itemContainer: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#fff',
    borderRadius: 8,
    shadowColor: '#000',
    shadowOffset: { width: 0, height: 2 },
    shadowOpacity: 0.8,
    shadowRadius: 2,
    elevation: 1,
  },
});

export default LoopingCarousel;

Other packages similar to react-native-reanimated-carousel

Keywords

react-native

FAQs

Package last updated on 11 Feb 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts