• Stars
    star
    208
  • Rank 188,560 (Top 4 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 7 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Items Carousel Built with react-motion and styled-components

react-items-carousel

Installation

$ npm install react-items-carousel --save

Demos

Example

import React, { useState } from 'react';
import ItemsCarousel from 'react-items-carousel';

export default () => {
  const [activeItemIndex, setActiveItemIndex] = useState(0);
  const chevronWidth = 40;
  return (
    <div style={{ padding: `0 ${chevronWidth}px` }}>
      <ItemsCarousel
        requestToChangeActive={setActiveItemIndex}
        activeItemIndex={activeItemIndex}
        numberOfCards={2}
        gutter={20}
        leftChevron={<button>{'<'}</button>}
        rightChevron={<button>{'>'}</button>}
        outsideChevron
        chevronWidth={chevronWidth}
      >
        <div style={{ height: 200, background: '#EEE' }}>First card</div>
        <div style={{ height: 200, background: '#EEE' }}>Second card</div>
        <div style={{ height: 200, background: '#EEE' }}>Third card</div>
        <div style={{ height: 200, background: '#EEE' }}>Fourth card</div>
      </ItemsCarousel>
    </div>
  );
};

Component Props

Property Type Default Description
children * node[] The cards to render in the carousel. You must specify a height for each card.
requestToChangeActive * function This function accepts the new activeItemIndex and should update your component state.
activeItemIndex * int This defines which item should be active.
numberOfCards number 3 Number of cards to show per slide.
infiniteLoop boolean false Enable infinite loop. see Infinite loop limitations
gutter number 0 Space between cards.
showSlither boolean false If true a slither of next card will be shown.
firstAndLastGutter boolean false If true first and last cards will have twice the space.
enablePlaceholder boolean false If true, component will render placeholderItem until children are passed.
placeholderItem node null If enablePlaceholder is true, this will be rendered until children are passed.
numberOfPlaceholderItems number 0 This controls how many placeholderItem to render if enablePlaceholder is true.
activePosition enum ('left', 'center', 'right') left The position of the active item.
rightChevron node null Right chevron node.
leftChevron node null Left chevron node.
chevronWidth number 0 This value should be the width of left and right chevron.
outsideChevron boolean false If true the chevron will be rendered outside the carousel.
alwaysShowChevrons boolean false If true the chevrons will always be visible even if there were no cards to scroll.
slidesToScroll number 1 Number of cards to scroll when right and left chevrons are clicked.
disableSwipe boolean false Disables left and right swiping on touch devices.
onStateChange func null This function will be called when state change with { isFirstScroll: Boolean, isLastScroll: Boolean }. It can be used to fetch more data for example.
classes { wrapper: string, itemsWrapper: string, itemsInnerWrapper: string, itemWrapper: string, rightChevronWrapper: string, leftChevronWrapper: string } {} An object of classes to pass to the carousel inner elements

Infinite Loop Limitations

If infiniteLoop was set to true, the following props are ignored

  • activePosition: will always be left
  • alwaysShowChevrons: will always be true

Contributing

To contribute, follow these steps:

  • Fork this repo.
  • Clone your fork.
  • Run yarn
  • Run yarn start:gh
  • Goto localhost:9000
  • Add your patch then push to your fork and submit a pull request

License

MIT

More Repositories

1

git-change-date

Simple CLI to change old commits author and committer dates.
JavaScript
114
star
2

laravel-angularjs-chat-app-tutorial

PHP
37
star
3

react-swipeable-tabs

JavaScript
32
star
4

angularjs-auth-tutorial

Managing user authentications and route access in angularjs
JavaScript
28
star
5

VineRelayStore

🔥 VineRelay is Content Management Boilerplate which enables you to quickly scaffold a shop with the basic features using React, Relay and GraphQL.
JavaScript
16
star
6

react-flux-todoapp

Typescript, ReactJs, Flux, ImmutableJS & RxJS in a Todo App
TypeScript
12
star
7

react-tutorial-connected-animation

React tutorial connected animation https://www.youtube.com/watch?v=3DNCFiIW3sU
JavaScript
11
star
8

react-tutorial-image-animation

Youtube video https://youtu.be/m-fBPMffIZ0
JavaScript
7
star
9

react-motion-grid

JavaScript
5
star
10

react-expandable

JavaScript
5
star
11

react-bottom-sheet

JavaScript
5
star
12

react-apple-carousel

JavaScript
5
star
13

react-shopping-cart-tutorial

Shopping cart with React, Redux and Redux saga
JavaScript
4
star
14

react-cube-image-reveal

JavaScript
2
star
15

angularjs-password-meter-tutorial

Create password strength meter using AngularJS and Bootstrap.
JavaScript
2
star
16

grcomponent

Command line tool to generate react components.
JavaScript
2
star
17

laravel-path-manager

Easy way to manage files and directories using urls.
PHP
2
star
18

react-tutorials

JavaScript
2
star
19

migs-payment-sample-code

PHP
2
star
20

GANN

Genetic algorithm neural network - Java, slick2d, neuroph
Java
1
star
21

transferwise-currency-alert

Shell
1
star
22

s3_bucket_test

HCL
1
star
23

monorepo-test

JavaScript
1
star
24

youtube-aws-101-instances

HCL
1
star
25

gann-jumping-game

https://www.youtube.com/watch?v=kdlt2eDxvvM
C#
1
star
26

chessclock-flutter

Dart
1
star
27

portkey

JavaScript
1
star
28

graphql-relay-tutorial-schema

Practical Tutorial: GraphQL and Relay (Getting started) https://www.youtube.com/watch?v=db2buIMLick
JavaScript
1
star
29

stock-prices-analysis

JavaScript
1
star
30

mo-law-studies

HTML
1
star
31

bash-utilities

Shell
1
star
32

philotic-handler-mobile-app

Mobile app that handles actions send by philotic-ansible-cli
Dart
1
star
33

project-tmp

JavaScript
1
star
34

philotic-ansible-cli

JavaScript
1
star
35

qbrando

JavaScript
1
star
36

hanoi-react

Hanoi game built with React
JavaScript
1
star
37

blog-frontend-app

JavaScript
1
star
38

hack-trex

Hack TRex Game with python and javascript
Python
1
star
39

tictactoe

Java
1
star
40

laravel-membership

PHP
1
star
41

classnames-css-selectors-prefixer

JavaScript
1
star
42

gann-service

https://www.youtube.com/watch?v=1YXsU3WUmnc
Java
1
star
43

vim-config

Shell
1
star