Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/akashuba/react-timeline-animation

react-timeline-animation component
https://github.com/akashuba/react-timeline-animation

Last synced: about 2 months ago
JSON representation

react-timeline-animation component

Awesome Lists containing this project

README

        

# React scroll animation component.
![test parameter](https://github.com/akashuba/react-timeline-animation/actions/workflows/playwright.yml/badge.svg)

#### Could be used for timeline filling or any animations related to scrolling and crossing the middle of the screen. Just wrap the animated component with TimelineObserver.


drawing

## Demo [codesandbox](https://codesandbox.io/s/brave-kepler-fdbzv?file=/src/App.js:0-1097) 🚀

## How to use it

### 1. Installation

```bash
npm install --save react-timeline-animation
```

or

```bash
yarn add react-timeline-animation
```
### 2. Quick start
Important to add a unique id to the observed element (id="timeline100500").
``` javascript

;
```

Component using react "render prop" pattern.

```javascript
(

)}
/>;
```

```javascript
const Timeline = ({ setObserver, callback }) => {
const timeline = useRef(null);

// It Will be fired when the element crossed the middle of the screen.
const someCallback = () => {
callback();
};

useEffect(() => {
if (timeline.current) {
setObserver(timeline.current, someCallback);
}
}, []);

return

;
};
```

## Options (props) 🛠

#### `initialColor`: not required. Initial color of observable element.

#### `fillColor`: not required. Color to fill element.

#### `handleObserve`: required. "render prop" to handle observable element.
#### `hasReverse`: not required. Allow to scroll in both directions.

```typescript
interface TimelineObserverProps {
handleObserve?: (
observer: (target: Element, callbackFn?: () => void) => void
) => JSX.Element;
initialColor?: string;
fillColor?: string;
hasReverse?: boolean;
}
```