GithubHelp home page GithubHelp logo

trendingtechnology / react-items-carousel Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kareemaly/react-items-carousel

0.0 1.0 0.0 1.29 MB

React items carousel

License: MIT License

JavaScript 98.19% HTML 1.81%

react-items-carousel's Introduction

react-items-carousel

Installing

$ npm install react-items-carousel --save

Demos

Example

import React from 'react';
import ItemsCarousel from 'react-items-carousel';
import range from 'lodash/range';

export default class Test extends React.Component {

  componentWillMount() {
    this.setState({
      children: [],
      activeItemIndex: 0,
    });

    setTimeout(() => {
      this.setState({
        children: createChildren(20),
      })
    }, 100);
  }

  createChildren = n => range(n).map(i => <div key={i} style={{ height: 200, background: '#333' }}>{i}</div>);

  changeActiveItem = (activeItemIndex) => this.setState({ activeItemIndex });

  render() {
    const {
      activeItemIndex,
      children,
    } = this.state;

    return (
      <ItemsCarousel
        // Placeholder configurations
        enablePlaceholder
        numberOfPlaceholderItems={5}
        minimumPlaceholderTime={1000}
        placeholderItem={<div style={{ height: 200, background: '#900' }}>Placeholder</div>}

        // Carousel configurations
        numberOfCards={3}
        gutter={12}
        showSlither={true}
        firstAndLastGutter={true}
        freeScrolling={false}

        // Active item configurations
        requestToChangeActive={this.changeActiveItem}
        activeItemIndex={activeItemIndex}
        activePosition={'center'}

        chevronWidth={24}
        rightChevron={'>'}
        leftChevron={'<'}
        outsideChevron={false}
      >
        {children}
      </ItemsCarousel>
    );  
  }
} 
Property Type Default Description
children* arrayOf (element) Carousel react items.
numberOfCards number 3 Number of cards to show.
gutter number 0 Space between carousel items.
showSlither bool false If true a slither of next item will be showed.
firstAndLastGutter bool false If true first item will have twice the
freeScrolling bool false If true, free scrolling will be enabled.
enablePlaceholder bool false Enable placeholder items while data loads
placeholderItem element Placeholder item. Ignored if enablePlaceholder is false.
numberOfPlaceholderItems number Number of placeholder items. Ignored if enablePlaceholder is false.
requestToChangeActive func This is called when we want to change the active item.
Right now we will never call this unless a left or right chevrons are clicked.
activeItemIndex number 0 This gives you the control to change the current active item.
This is ignored if freeScrolling is true.
activePosition enum ('left', 'center', 'right') 'left' The active item position.
This is ignored if freeScrolling is true.
rightChevron union (
element,
string
)
Right chevron element. If passed requestToChangeActive must be set.
leftChevron union (
element,
string
)
Left chevron element. If passed requestToChangeActive must be set.
chevronWidth number Chevron width.
outsideChevron bool If true the chevron will be outside the carousel.
slidesToScroll number 1 Number of slides to scroll when clicked on right or left chevron.
springConfig shape {
stiffness: number
damping: number
precision: number
}
React motion configurations.
More about this here

Contributing

To contribute, follow these steps:

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

License

MIT

react-items-carousel's People

Contributors

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