Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-simply-carousel

Package Overview
Dependencies
Maintainers
1
Versions
75
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-simply-carousel

Simple react.js carousel component

  • 2.1.5
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
8K
decreased by-7.75%
Maintainers
1
Weekly downloads
 
Created
Source

npm version npm bundle size GitHub license

Simple && small controlled React.js carousel component (touch enabled, infnite and responsive)

Table of contents

Installation

npm

npm install react-simply-carousel --save

yarn

yarn add react-simply-carousel

Usage

Basic Example:
import React, { Component } from 'react';
import Carousel from 'react-simply-carousel';

class App extends Component {
  state = {
    activeSlideIndex: 0,
  }

  setActiveSlideIndex = (newActiveSlideIndex) => {
    this.setState({
      activeSlideIndex: newActiveSlideIndex
    });
  }

  render() {
    return (
      <Carousel
        activeSlideIndex={this.state.activeSlideIndex}
        onRequestChange={this.setActiveSlideIndex}
        itemsToShow={3}
        itemsToScroll={3}
      >
        <div style={{ width: 300, height: 300 }}>slide 0</div>
        <div style={{ width: 300, height: 300 }}>slide 1</div>
        <div style={{ width: 300, height: 300 }}>slide 2</div>
        <div style={{ width: 300, height: 300 }}>slide 3</div>
        <div style={{ width: 300, height: 300 }}>slide 4</div>
        <div style={{ width: 300, height: 300 }}>slide 5</div>
        <div style={{ width: 300, height: 300 }}>slide 6</div>
        <div style={{ width: 300, height: 300 }}>slide 7</div>
        <div style={{ width: 300, height: 300 }}>slide 8</div>
        <div style={{ width: 300, height: 300 }}>slide 9</div>
      </Carousel>
    );
  }
}

Props

NameTypeDefault ValueDescription
activeSlideIndexnumberIndex of first visible children (slide)
activeSlidePropsobject{}DOM props for first visible slide element
autoplaybooleanfalseBoolean indicating if the carousel should be updated automatically
autoplayDirectionstring ('forward' or 'backward')'forward'Direction of automatically updates
backwardBtnPropsobject{}Contain DOM props for carousel backward button element, boolean prop show (for toggle button render) and node prop children (for render button childrens)
childrennodenullArray of slides
containerPropsobject{}DOM props for container div element
delaynumber0Slide change delay (css transition delay) in ms
disableNavIfAllVisiblebooleantrueBoolean indicating if the carousel nav (by nav buttons, click on slide item, mouse move or touch move) should be disabled if all slides is visible
easingstring'linear'Slide change easing (css transition easing)
forwardBtnPropsobject{}Contain DOM props for carousel forward button element, boolean prop show (for toggle button render) and node prop children (for render button childrens)
hideNavIfAllVisiblebooleantrueBoolean indicating if the carousel nav buttons should be hidden if all slides is visible
innerPropsobject{}DOM props for inner div element
itemsListPropsobject{}DOM props for items list div element
itemsToScrollnumber1number of slides that should be scrolled to hidden part of carousel
itemsToShownumber0 (automaticaly calculated)number of slides that should be visible
onAfterChangefunctionnullFunction that will be run after all updates is done and carousel moving is end
onRequestChangefunctionFunction that will be run when the activeSlideIndex is requested to be changed (either by clicking on navigation button, clicking on slide (if prop updateOnItemClick value is true ), or after drag slides)
responsivePropsArray of objects[]carousel props for different window width. For example: [{minWidth: 768, maxWidth: 992, itemsToShow: 3}, {maxWidth: 767, itemsToShow: 1}] will show only one slide when window width is less than 767px and show 3 slides when window width is >= 768px and < 992px
speednumber0Slide change speed (css transition speed) in ms
updateOnItemClickbooleanfalseBoolean indicating if the onRequestChange prop should be called after click on some slide

Demo

Edit react-simply-carousel-demo

Keywords

FAQs

Package last updated on 21 Nov 2019

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc