@iquji-web/web-motion 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +69 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,5 +1,71 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @iquji-web/web-motion
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
简体中文 | [English](README.en.md)
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Iquji Web 动效原语库,基于 Framer Motion 精简封装,提供控制级、浮层级及路由级的标准过渡时长、缓动曲线与 Variants,原生适配操作系统的 `prefers-reduced-motion` 偏好。
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 安装
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install @iquji-web/web-motion framer-motion
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## 核心特性与使用
|
|
18
|
+
|
|
19
|
+
### 1. Provider 包装
|
|
20
|
+
|
|
21
|
+
在应用外层配置 `IqujiMotionProvider`:
|
|
22
|
+
|
|
23
|
+
```tsx
|
|
24
|
+
import { IqujiMotionProvider } from "@iquji-web/web-motion";
|
|
25
|
+
|
|
26
|
+
export function App({ children }) {
|
|
27
|
+
return (
|
|
28
|
+
<IqujiMotionProvider reducedMotion="user">
|
|
29
|
+
{children}
|
|
30
|
+
</IqujiMotionProvider>
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### 2. 页面与元素进场动效
|
|
36
|
+
|
|
37
|
+
```tsx
|
|
38
|
+
import { IqujiMotion, iqujiMotionPresets, iqujiMotionVariants } from "@iquji-web/web-motion";
|
|
39
|
+
|
|
40
|
+
export function PageTransition({ children }) {
|
|
41
|
+
return (
|
|
42
|
+
<IqujiMotion.div
|
|
43
|
+
initial={iqujiMotionVariants.route.initial}
|
|
44
|
+
animate={iqujiMotionVariants.route.enter}
|
|
45
|
+
transition={iqujiMotionPresets.route}
|
|
46
|
+
>
|
|
47
|
+
{children}
|
|
48
|
+
</IqujiMotion.div>
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## 预设与时长标准
|
|
56
|
+
|
|
57
|
+
- **控件级 (`control`)**:时长 `0.14s`,用于按钮、选择器微交互。
|
|
58
|
+
- **浮层级 (`overlay`)**:时长 `0.19s`,用于弹窗、抽屉进入与退出。
|
|
59
|
+
- **路由级 (`route`)**:时长 `0.24s`,用于页面切换平滑位移。
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## 开发与构建
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
bun install --frozen-lockfile
|
|
67
|
+
bun run build # 编译打包到 dist/
|
|
68
|
+
bun run typecheck # 类型校验
|
|
69
|
+
bun run test # 单元测试
|
|
70
|
+
bun run check # 完整校验
|
|
71
|
+
```
|