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

https://github.com/zhangyu1818/motion-wave

Animate your waves with ease!
https://github.com/zhangyu1818/motion-wave

animated-wave wave waveform

Last synced: 3 months ago
JSON representation

Animate your waves with ease!

Awesome Lists containing this project

README

        

# Motion Wave 🌊

![npm bundle size](https://img.shields.io/bundlephobia/minzip/motion-wave)

---

[English](./README-zh_CN.md) | 简体中文

开箱即用,简单的方式让你的波浪动起来 🤩

[**demo**](https://zhangyu1818.github.io/motion-wave/)

## 功能 ✨

- 波浪组件直接使用!
- 流畅的动画,让你的波浪更有质感!
- 通过 Hook 创建波浪,更具自定义!
- 不用 React?原生也能用!

## 安装 📦

```shell
pnpm install motion-wave
```

## WaveConfig 配置参数

**frequency**

- 类型:`number`
- 波浪周期

**amplitude**

- 类型: `number`
- 波浪高度

**phase**

- 类型: `number`
- 波浪水平位置

**speed**

- 类型: `number`
- 波浪动画速度

**offset**

- 类型: `number`
- 波浪上下位置

**color**

- 类型: `string`
- 波浪颜色

## 组件使用

**``**

```jsx
function App() {
return (

)
}
```

**``**

[![Edit dreamy-booth-tw5w5k](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/dreamy-booth-tw5w5k?fontsize=14&hidenavigation=1&theme=dark)

```jsx
function App() {
return (

)
}
```

`MotionConfig`的详细配置,请参阅[framer-motion](https://www.framer.com/motion/transition/)。

## Hook

```
useWave(config:WaveConfig, ref?: unknown)
```

示例:

```jsx
const Wave = props => {
const [canvasRef, handler] = useWave(props)

return (


handler.current.stop()}>stop


)
}
```

## createWave 原生使用

```
createWave(canvas: HTMLCanvasElement, config: WaveConfig)
```

示例:

```js
const handler = createWave(document.querySelector('#canvas'), {
frequency: 1,
amplitude: 200,
})
```

## LICENSE

[MIT License](https://github.com/zhangyu1818/motion-wave/blob/main/LICENSE)