Skip to content

synaphea/react-animated-slider

 
 

Repository files navigation

react-animated-slider

CircleCI dependencies devDependencies downloads

Animated slider component for react.

Demo - Playground

Preview

Features:

  • Ready to use slider component with animations
  • Easy customization
  • Horizontal or vertical navigation
  • Swipe navigation on touch devices
  • Infinite slider
  • Supports any element as children
  • Clean DOM without dirty manipulations
  • Works with SSR
  • Works on IE11

Install:

npm install react-animated-slider --save

Most Simple Use:

import Slider from 'react-animated-slider';
import 'react-animated-slider/build/horizontal.css';

<Slider>
  {content.map((article, index) => <div key={index}>
    <h2>{article.title}</h2>
    <div>{article.description}</div>
  </div>)}
</Slider>

Properties:

slideIndex - number, default 0

Index of the slide that will be initially displayed.

duration - number, default 2000(ms)

Duration of the animation in milliseconds. It is used to remove the animateIn and animateOut classNames and assign current after the transition has completed.

disabled - boolean, default false

Disable slider navigation

infinite - boolean, default true

Enable or disable infinite loop through slides. Sliders with only 2 children will have this option set to false

minSwipeOffset - number, default 15(px)

Minimum distance to swipe for triggering a navigation event

previousButton - ReactElement, default string "previous"

Will be rendered inside the previous button

nextButton - ReactElement, default string "next"

Will be rendered inside the next button

classNames object, default

{
  previousButton: 'previousButton',
  nextButton: 'nextButton',
  track: 'track',
  slide: 'slide',
  hidden: 'hidden',
  previous: 'previous',
  current: 'current',
  next: 'next',
  animateIn: 'animateIn',
  animateOut: 'animateOut',
}

Object representing the CSS classNames that will be apllied to the slides.

Classnames

previousButton

nextButton

track element wrapping all slides

slide apllied to every item (child)

hidden a slide that is not visible and is not adjacent to the current slide, therefore no animation will be usually needed

previous the slide that will appear or is appearing when the slider navigated back

next the slide that will appear or is appearing when the slider navigated forward

animateIn the slide moving into the view

animateOut the slide moving out of the view

About

Animated slider component for react

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 93.7%
  • CSS 6.3%