# reactjs-draggable-slider

> Smooth draggable React slider for project items using Spring and GSAP

Latest version **1.0.0** (published 2022-08-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install reactjs-draggable-slider
pnpm add reactjs-draggable-slider
yarn add reactjs-draggable-slider
bun add reactjs-draggable-slider
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2022-08-24 |
| First published | 2022-08-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 313.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Mobin Veisy |
| Maintainers | mobinveisy |
| Keywords | react, slider, draggable, projects, slide, portfolio, gsap, spring |

## Links

- npm: https://www.npmjs.com/package/reactjs-draggable-slider
- Repository: https://github.com/mobinveisy/react-draggable-slider
- Homepage: https://github.com/mobinveisy/react-draggable-slider#readme
- Issues: https://github.com/mobinveisy/react-draggable-slider/issues
- npm.io page: https://npm.io/package/reactjs-draggable-slider

## Dependencies (3)

- [react](https://npm.io/package/react.md) ^16.13.1
- [react-dom](https://npm.io/package/react-dom.md) ^16.13.1
- [prop-types](https://npm.io/package/prop-types.md) ^15.7.2

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2022-08-24

## README

# reactjs-draggable-slider

![GitHub](#) 
[![NPM Downloads]()]()  

<p align="left">NPM package for my custom Draggable React Slider using React Spring and GSAP.</p>

<p align="center">by <mark color="red">Mobin veisy</mark></p>

![gif](https://media.giphy.com/media/gKNT6B5MkMnp4sHMiT/giphy.gif) 
![gif-mobile](https://media.giphy.com/media/jmwmKtZR553jULsnCR/giphy.gif)

## Installation

```
npm install react-draggable-slider --save-dev
```

### Demo



## Usage

Add `<Slider />` component with sliderSettings object, the only required setting an array of slider items.

```jsx
import { Slider } from "react-draggable-slider";
import { projectList } from "./data";

function App() {
  const sliderSettings = {
    data: projectList,
    speed: 3000,
    easing: "elastic",
    bgColor: "rgba(255, 255, 255, 0.05)",
    buttonHref: "https://www.google.com",
    buttonTarget: "_self",
    buttonText: "View project",
    showButton: true,
  };
  return <Slider sliderSettings={sliderSettings} />;
}
```

Use the following structure for your slider items:

```javascript
export const projectList = [
  {
    title: "Cutting Edge Project",
    image: "https://source.unsplash.com/collection/347317/",
    description: "Praesent quis congue nisi...",
  },
  {
    title: "Featured Artist 3D",
    image: "https://source.unsplash.com/collection/3573299/",
    description: "Duis at tellus vitae velit aliquet varius...",
  },
];
```

> **Note:** although the above example uses hooks, react-draggable-slider is compatible with Class-based components. However, since it internally uses hooks, it requires React `16.8+`.

### Props

The sliderSettings prop in `<Slider sliderSettings={sliderSettings} />` component accepts the following props:

| Name         | Type      | Description                                                                          | Default Value               |
| ------------ | --------- | ------------------------------------------------------------------------------------ | --------------------------- |
| `data`       | `array`   | array of slider items, see below which structure you may use                         | `[]`                        |
| `speed`      | `number`  | speed of sliding to next item when dragged in milliseconds                           | 3000 (3 seconds)            |
| `easing`     | `string`  | 4 available GSAP easings to animate the sliding: "power", "back", "elastic", "expo". | ease                        |
| `bgColor`    | `string`  | Set background-color of the whole slider, accepts HEX and RGB(A).                    | `rgba(255, 255, 255, 0.05)` |
| `buttonText` | `string`  | Text inside button per item                                                          | `View case study`           |
| `showButton` | `boolean` | If a button should be shown for all items                                            | `true`                      |

### Using

- React Spring
- GSAP
- Styled Components

#### Mobin Veisy - 2022

---
_Source: https://npm.io/package/reactjs-draggable-slider · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
