Giter VIP home page Giter VIP logo

re-carousel's Introduction

re-carousel npm-version

Minimal carousel component for React.

demo: https://amio.github.io/re-carousel/

Usage

import Carousel from 're-carousel'

then:

<Carousel auto>
  <div style={{backgroundColor: 'tomato', height: '100%'}}>Frame 1</div>
  <div style={{backgroundColor: 'orange', height: '100%'}}>Frame 2</div>
  <div style={{backgroundColor: 'orchid', height: '100%'}}>Frame 3</div>
</Carousel>

Attributes

All attributes are optional.

  • axis {enum} 'x' or 'y' ('x' by default)

  • loop {boolean} true or false (false by default) toggle loop mode.

  • auto {boolean} true or false (false by default) toggle auto sliding.

  • interval {number} (4000ms by default) interval for auto sliding.

  • duration {number} (300ms by default) duration for animation.

  • widgets {Array of ReactClass} Indicator and switcher could be various, so it's not builtin. Here's some example custom widgets (dots indicator, prev/next buttons):

    import Carousel from 're-carousel'
    import IndicatorDots from './indicator-dots'
    import Buttons from './buttons'
    
    export default function carousel () {
      return <Carousel loop auto widgets={[IndicatorDots, Buttons]}>
        <div style={{backgroundColor: 'tomato', height: '100%'}}>Frame 1</div>
        <div style={{backgroundColor: 'orange', height: '100%'}}>Frame 2</div>
        <div style={{backgroundColor: 'orchid', height: '100%'}}>Frame 3</div>
      </Carousel>
    }
  • frames {Array of ReactElement} If you want to create frames programmatically, use this attribute:

    import Carousel from 're-carousel'
    
    export default function carousel (props) {
      const frames = props.frameArray.map((frame, i) => {
        return <div>Frame {i}</div>
      })
      return <Carousel auto frames={frames}>
        <span>These children element will be appended to Carousel,</span>
        <span>as normal element other than "frame".</span>
      </Carousel>
    }

Contributes

npm run start # start local dev server
npm run build # build lib
npm run test  # run tests

License

MIT © Amio

re-carousel's People

Contributors

amio avatar appzter avatar cordazar avatar greenkeeper[bot] avatar revolunet avatar

Watchers

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