An open API service indexing awesome lists of open source software.

https://github.com/zavalit/steper

A lightweight JavaScript library for draggable and slider animations
https://github.com/zavalit/steper

Last synced: 9 months ago
JSON representation

A lightweight JavaScript library for draggable and slider animations

Awesome Lists containing this project

README

          

# Steper

A lightweight JavaScript library for draggable and slider animations.

![steper](./demo/public/logo_proposal.webp)

[Demo Examples](https://steper.netlify.app/)

## Installation

```bash
npm install steper
```

## Usage

HTML markup
````html


  • slide 1

  • slide 2

  • slide 3

left
right

````
Javascript Logic
```js
import { useDraggableAnimation, useSliderAnimation } from 'steper';

const steperRef = document.getElementById('slider')

//make it draggable
useDraggableAnimation(steperRef);

// and or slide it
const move = useSliderAnimation(steperRef);
// to left
document.getElementById('left').addEventListener('click', () => move(-1))
// to right
document.getElementById('right').addEventListener('click', () => move(1))
````

## API

### useDraggableAnimation(ref, onDragStart, onDragEnd)
* `ref`: The reference to the HTML element.
* `onDragStart`: Callback function when dragging starts.
* `onDragEnd`: Callback function when dragging ends.

### useSliderAnimation(ref, duration, onSlideStart, onSlideEnd)
* `ref`: The referenceC to the HTML element.
* `duration`: Duration of the slide animation in seconds.
* `onSlideStart`: Callback function when sliding starts.
* `onSlideEnd`: Callback function when sliding ends.

## License

MIT