Coder Social home page Coder Social logo

cawfree / react-native-rotary Goto Github PK

View Code? Open in Web Editor NEW
37.0 4.0 3.0 3 MB

๐Ÿ•ฐ๏ธ A <Rotary /> component for React Native.

License: MIT License

JavaScript 100.00%
loop infinite scroll react react-native react-native-web carousel enum

react-native-rotary's Introduction

๐Ÿ•ฐ๏ธ react-native-rotary

A <Rotary /> component for React Native, compatible with Android, iOS and Web, powered by react-native-animated-math.

This project supports Semantic Versioning.

๐Ÿš€ Getting Started

Using npm:

npm install --save react-native-rotary

Using yarn:

yarn add react-native-rotary

๐Ÿ”ฅ Features

  • Dynamic paginated rotation control via the index prop.
  • Smoothly animated infinite content loops, without the need for duplicate entries, scroll limits or jitter.

โœ๏ธ Example

This component emulates the configuration of a <FlatList />.

import React, { useState } from 'react';
import { View, StyleSheet, Image } from 'react-native';
import Rotary from 'react-native-rotary';
 
export default () => {
  // You can define an initial index offset, and render arbitrary child elements.
  const [ index, setIndex ] = useState(1);
  return (
    <View
      style={[
        StyleSheet.absoluteFill,
        {
          alignItems: 'center',
          justifyContent: 'center',
        },
      ]}
    >
      <Rotary
        index={index}
        onIndexChanged={setIndex}
        radius={100}
        data={data}
        renderItem={({ item: uri, index }) => (
          <View
            style={{
              width: 100,
              height: 100,
              alignItems: 'center',
              justifyContent: 'center',
            }}
          >
            <Image
              style={{
                width: 80,
                height: 80,
              }}
              source={{ uri }}
            />
          </View>
        )}
      />
      <View
        style={{
          width: 50,
          height: 50,
        }}
      />
    </View>
  );
};
 
const data = [
  'https://mondrian.mashable.com/uploads%252Fcard%252Fimage%252F929108%252F46c9313d-32d0-4da8-8d41-f5e50936a926.png%252Ffull-fit-in__950x534.png?signature=_R0yeIihD3oDvF1bulncd718gR0=&source=https%3A%2F%2Fblueprint-api-production.s3.amazonaws.com',
  'https://cdn-01.independent.ie/incoming/article34131003.ece/bcec2/AUTOCROP/w620/Hugging%20Face.png',
  'https://i2.wp.com/www.emojifoundation.com/wp-content/uploads/2017/07/Thinking_Face_Emoji.png',
  'https://cdn.shopify.com/s/files/1/1061/1924/products/Unamused_Face_Emoji_761d8bf8-c78c-45b1-80b1-a86a80d2452d_grande.png?v=1480481058',
  'https://cdn.shopify.com/s/files/1/1061/1924/products/Cold_Sweat_Emoji_grande.png?v=1480481051',
  'https://thumbor.forbes.com/thumbor/960x0/https%3A%2F%2Fblogs-images.forbes.com%2Fdavidphelan%2Ffiles%2F2017%2F07%2Femoji_update_2017_10.jpg',
  'https://cdn.shopify.com/s/files/1/1061/1924/products/Face_with_Cold_Sweat_Emoji_grande.png?v=1480481052',
  'https://www.dictionary.com/e/wp-content/uploads/2018/03/Upside-Down_Face_Emoji.png',
];

๐Ÿ“Œ Props


Prop Type Default Required Description
radius number 60 No The radius of the circle the rendered items will render around.
data arrayOf[object Object] [] No The data source to render.
renderItem func ({ item, index }) => null No A function to render an item from data.
index number 0 No The currently focused index.
onIndexChanged func (index) => null No Callback for when the index has changed.
duration number 300 No The animation duration when rendered items are realigned.
minSwipe number 0 No The minimum amount of distance to drag before rotating.
style object 0 No Additional styling.
disabled bool false No Prevent manual scrolling.

โœŒ๏ธ License

MIT

Buy @cawfree a coffee

react-native-rotary's People

Contributors

cawfree avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

react-native-rotary's Issues

Hello

Hi, I followed the steps to install it and I have a problem. It says:
./node_modules/react-native-rotary/index.js
SyntaxError: C:\Users\lenovo\Desktop\exam2019\node_modules\react-native-rotary\index.js: Unexpected token (93:12)

91 | );
92 | return (

93 | <Animated.View
| ^
94 | key={index}
95 | style={{
96 | opacity: scale,

Do I have to install something else?
Thank you!

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.