1.0.0 • Published 5 years ago

react-stacker v1.0.0

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

react-stacker

Carousel / slider component built with React.js. It’s flexible, fast and touch-friendly.

Imgur

Examples

Getting started

Install react-stacker using npm.

npm install --save react-stacker

or if you prefer yarn

yarn add react-stacker

Usage

import React from "react";
import ReactDOM from "react-dom";
import { StackerSlide, StackerSlider } from "react-stacker";

export class App extends React.Component {
    onChangeHandler = value => {
        console.log("On change slide");
    };

    onPrevChangeHandler = event => {
        console.log("On prev change slide");
    };

    onNextChangeHandler = event => {
        console.log("On next change slide");
    };

    render() {
        const { value } = this.state;
        return (
            <StackerSlider
               dots={true}
                infiniteLoop={true}
                onChange={this.onChangeHandler}
                onPrevChange={this.onPrevChangeHandler}
                onNextChange={this.onNextChangeHandler}
            >
                <StackerSlide>
                    Slide 6/6
                </StackerSlide>
                <StackerSlide>
                    Slide 5/6
                </StackerSlide>
                <StackerSlide>
                    Slide 4/6
                </StackerSlide>
                <StackerSlide>
                    Slide 3/6
                </StackerSlide>
                <StackerSlide>
                    Slide 2/6
                </StackerSlide>
                <StackerSlide>
                    Slide 1/6
                </StackerSlide>
            </StackerSlider>
        );
    }
}

ReactDOM.render(<App />, document.getElementById("root"));

Props

PropsTypeDefaultDescription
classNamestring--
zDistancenumber50Distance between slides by z axis
yDistancenumber30Distance between slides by y axis
transitionDurationnumber0.8Slide transition speed. Number of milliseconds accepted.
infiniteLoopbooleantrueFlag to make the carousel loop around when it reaches the end.
dotsbooleanfalseFlag to render pagination component.
dotsColorstring#0000007dThe fill color of pagination dots. Any valid CSS color is accepted
dotsActiveColorstring#ff0000The fill color of the active pagination dot. Any valid CSS color is accepted.
dotsSizestring8pxThe size of each pagination dot. Pixel values are accepted.
dotsPaddingstring6pxThe padding inside each pagination dot. Pixel values are accepted.
slideWidthstring-Weight of the slides.
slideHeightstring-Height of the slides.

Events

EventTypeEmitter
onChangefunctioncarousel
onPrevChangefunctioncarousel
onNextChangefunctioncarousel

Contributing

  • For bugs and feature requests, please create an issue
  • Lint and test your code
  • Pull requests and ⭐ stars are always welcome

Raising issues

When raising an issue, please add as much details as possible. Screenshots, video recordings, or anything else that can make it easier to reproduce the bug you are reporting.

License

This project is licensed under the MIT License