# @igorriti/react-fluid-animation

> Fluid media animation for React powered by WebGL.

Latest version **0.0.2** (published 2023-02-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install @igorriti/react-fluid-animation
pnpm add @igorriti/react-fluid-animation
yarn add @igorriti/react-fluid-animation
bun add @igorriti/react-fluid-animation
```

## Health

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

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.2 |
| Published | 2023-02-01 |
| First published | 2023-02-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=14 |
| Dependencies | 3 |
| Unpacked size | 211.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | igorriti |
| Maintainers | igorriti |
| Keywords | react, fluid, animation, webgl |

## Links

- npm: https://www.npmjs.com/package/@igorriti/react-fluid-animation
- Repository: https://github.com/igorriti/react-fluid-animation
- Issues: https://github.com/igorriti/react-fluid-animation/issues
- npm.io page: https://npm.io/package/@igorriti/react-fluid-animation

## Dependencies (3)

- [raf](https://npm.io/package/raf.md) ^3.4.1
- [color](https://npm.io/package/color.md) ^3.1.3
- [react-sizeme](https://npm.io/package/react-sizeme.md) ^3.0.1

## 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

- 0.0.2 (latest) — 2023-02-01
- 0.0.1 — 2023-02-01

## README

## Installation

```bash
npm install @igorriti/react-fluid-animation
```

or

```bash
yarn add @igorriti/react-fluid-animation
```

## Usage


```jsx
import ReactFluidAnimation from '@igorriti/react-fluid-animation';

export default function App() {
  return (
    <ReactFluidAnimation />
  );
}

```

## Usage with server-side rendering

This package works only on client side because it depdends on WebGL technology.

We need to load package dynamically after the hydration process is complete.

Let's see how this can be done:

```jsx
const DynamicAnimation = dynamic(() => import('@igorriti/react-fluid-animation'));

export default function App() {
  const [isAfterHydration, setIsAfterHydration] = useState<boolean>(false);
  
  useEffect(() => {
    if (!isAfterHydration) setIsAfterHydration(true);
  }, [isAfterHydration, setIsAfterHydration]);

  return isAfterHydration ? <DynamicAnimation /> : null;
}

```

This workaround give us the opportunity to dynamically load the component and mount it right after hydration is complete to get around hydration errors from React.

## Props & types

#### Props of the `ReactFluidAnimation` component:

```typescript
export interface Props {
  config?: IAnimationConfig; // animation config
  style?: object; // styles object passed to container <div>
  animationRef?: (animation: Animation) => void, // function to capture animation object
}
```

#### Animation config



```typescript
export interface IAnimationConfig {
  textureDownsample: number;
  densityDissipation: number;
  velocityDissipation: number;
  pressureDissipation: number;
  pressureIterations: number;
  curl: number;
  splatRadius: number;
}
```

#### Animation object

```typescript
export class Animation {
  config: IAnimationConfig; // current config of the animation
  width: number; // width of the canvas
  height: number; // height of the canvas
  addRandomSplats(count: number): void; // function to apply random splats on screen
}
```

---
_Source: https://npm.io/package/@igorriti/react-fluid-animation · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
