react-animated-slider

WebJar for react-animated-slider

License

License

MIT
Categories

Categories

IDE Development Tools React User Interface Web Frameworks
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

react-animated-slider
Last Version

Last Version

1.0.2
Release Date

Release Date

Type

Type

jar
Description

Description

react-animated-slider
WebJar for react-animated-slider
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/erichbehrens/react-animated-slider

Download react-animated-slider

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/react-animated-slider/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>react-animated-slider</artifactId>
    <version>1.0.2</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/react-animated-slider/
implementation 'org.webjars.npm:react-animated-slider:1.0.2'
// https://jarcasting.com/artifacts/org.webjars.npm/react-animated-slider/
implementation ("org.webjars.npm:react-animated-slider:1.0.2")
'org.webjars.npm:react-animated-slider:jar:1.0.2'
<dependency org="org.webjars.npm" name="react-animated-slider" rev="1.0.2">
  <artifact name="react-animated-slider" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='react-animated-slider', version='1.0.2')
)
libraryDependencies += "org.webjars.npm" % "react-animated-slider" % "1.0.2"
[org.webjars.npm/react-animated-slider "1.0.2"]

Dependencies

compile (1)

Group / Artifact Type Version
org.webjars.npm : react jar [16.2.0,17)

Project Modules

There are no modules declared in this project.

react-animated-slider

npm version downloads Greenkeeper badge CircleCI dependencies devDependencies minified size minified + gzipped size

A Slider/Carousel component for React supporting custom css animations.

Demo - Codesandbox Playground

Preview

Features

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

Install

npm install react-animated-slider

Note: this component relies on getDerivedStateFromProps and requires [email protected] or newer. For older react versions please install react-animated-slider version 1:

npm install react-animated-slider@^1

Most Simple Use

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

const slides = [
  { title: 'First item', description: 'Lorem ipsum'}
  { title: 'Second item', description: 'Lorem ipsum'}
];

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

Properties

property type default description
slideIndex number 0 Index of the slide that will be initially displayed.
duration number 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 false Disable slider navigation
infinite boolean true Enable or disable infinite loop through slides. Sliders with only 2 children will have this option set to false
autoplay number undefined Autoplay interval in miliseconds. If undefined the slider will not play automatically. The timer will be paused and reset during user interactions such as mouse over or touch, to avoid sliding away the elements when the user wants to click them.
touchDisabled boolean false Disable slider navigation through touch events
minSwipeOffset number 15(px) Minimum distance in pixels to swipe for triggering a navigation event
previousButton ReactElement arrow svg Will be rendered inside the previous button
nextButton ReactElement arrow svg Will be rendered inside the next button
classNames object see below Object representing the CSS classNames that will be apllied to the slides.
{
  slider: 'slider',
  previousButton: 'previousButton',
  nextButton: 'nextButton',
  buttonDisabled: 'disabled',
  track: 'track',
  slide: 'slide',
  hidden: 'hidden',
  previous: 'previous',
  current: 'current',
  next: 'next',
  animateIn: 'animateIn',
  animateOut: 'animateOut',
}

Classnames

class description
slider element wrapping the whole Slider
previousButton previous button
nextButton next button
buttonDisabled disabled state for previous and next button
track element wrapping all slides
slide apllied to every child item
hidden a slide that is not visible and is not adjacent to the current slide, therefore no animation will be applied
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

Events

property description
onSlideChange called after a slide change animation has ended. Receives an object with the new slide index as argument:
<Slider onSlideChange={event => console.log(event.slideIndex)}>

Versions

Version
1.0.2