@hua-labs/motion-core 2.1.0 → 2.2.0
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/LICENSE +21 -0
- package/README.md +86 -92
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +12 -12
- package/dist/.tsbuildinfo +0 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 HUA Labs Team
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,92 +1,86 @@
|
|
|
1
|
-
# @hua-labs/motion-core
|
|
2
|
-
|
|
3
|
-
Production-ready React animation hooks — zero dependencies, SSR-ready.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
[
|
|
1
|
+
# @hua-labs/motion-core
|
|
2
|
+
|
|
3
|
+
Production-ready React animation hooks — zero dependencies, SSR-ready.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@hua-labs/motion-core)
|
|
6
|
+
[](https://www.npmjs.com/package/@hua-labs/motion-core)
|
|
7
|
+
[](https://github.com/HUA-Labs/HUA-Labs-public/blob/main/LICENSE)
|
|
8
|
+
[](https://www.typescriptlang.org/)
|
|
9
|
+
[](https://reactjs.org/)
|
|
10
|
+
|
|
11
|
+
## Overview
|
|
12
|
+
|
|
13
|
+
A collection of 25+ React animation hooks built on a ref-based engine. Direct DOM manipulation for consistent performance with zero external dependencies. All hooks are TypeScript-native and SSR-compatible.
|
|
14
|
+
|
|
15
|
+
## Features
|
|
16
|
+
|
|
17
|
+
- **25+ animation hooks** — Fade, slide, scale, scroll, interactions, gestures
|
|
18
|
+
- **Zero dependencies** — Pure JavaScript motion engine
|
|
19
|
+
- **Ref-based** — Direct DOM manipulation for consistent performance
|
|
20
|
+
- **SSR compatible** — Works with Next.js, Remix, and SSR frameworks
|
|
21
|
+
- **Tested** — 517 test cases
|
|
22
|
+
|
|
23
|
+
## Installation
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
pnpm add @hua-labs/motion-core
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Peer dependencies: `react >= 19.0.0`, `react-dom >= 19.0.0`
|
|
30
|
+
|
|
31
|
+
## Quick Start
|
|
32
|
+
|
|
33
|
+
```tsx
|
|
34
|
+
import { useFadeIn, useSlideUp } from '@hua-labs/motion-core';
|
|
35
|
+
|
|
36
|
+
function Hero() {
|
|
37
|
+
const fadeIn = useFadeIn({ duration: 800 });
|
|
38
|
+
const slideUp = useSlideUp({ delay: 200 });
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<div>
|
|
42
|
+
<h1 ref={fadeIn.ref} style={fadeIn.style}>Welcome</h1>
|
|
43
|
+
<p ref={slideUp.ref} style={slideUp.style}>Animated content</p>
|
|
44
|
+
</div>
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## API Overview
|
|
50
|
+
|
|
51
|
+
All hooks return a consistent `BaseMotionReturn` interface:
|
|
52
|
+
|
|
53
|
+
| Property | Type | Description |
|
|
54
|
+
|----------|------|-------------|
|
|
55
|
+
| `ref` | `RefObject<T>` | Attach to target element |
|
|
56
|
+
| `style` | `CSSProperties` | Apply to element |
|
|
57
|
+
| `isVisible` | `boolean` | Visibility state |
|
|
58
|
+
| `isAnimating` | `boolean` | Animation in progress |
|
|
59
|
+
| `start/stop/reset/pause/resume` | `() => void` | Playback controls |
|
|
60
|
+
|
|
61
|
+
**Available hooks by category:**
|
|
62
|
+
|
|
63
|
+
| Category | Hooks |
|
|
64
|
+
|----------|-------|
|
|
65
|
+
| Basic | `useFadeIn`, `useSlideUp`, `useSlideLeft`, `useSlideRight`, `useScaleIn`, `useBounceIn`, `usePulse`, `useSpringMotion`, `useGradient` |
|
|
66
|
+
| Interaction | `useHoverMotion`, `useClickToggle`, `useFocusToggle`, `useToggleMotion` |
|
|
67
|
+
| Scroll | `useScrollReveal`, `useScrollProgress` |
|
|
68
|
+
| List | `useStaggerMotion`, `useCardList`, `useSkeleton` |
|
|
69
|
+
| Utility | `useMotionState`, `useRepeat`, `useSmartMotion`, `useUnifiedMotion`, `useSimplePageMotion`, `usePageMotions`, `useGesture`, `useGestureMotion` |
|
|
70
|
+
|
|
71
|
+
## Documentation
|
|
72
|
+
|
|
73
|
+
- [Detailed Guide](./DETAILED_GUIDE.md)
|
|
74
|
+
- [Documentation Site](https://docs.hua-labs.com)
|
|
75
|
+
|
|
76
|
+
## Related Packages
|
|
77
|
+
|
|
78
|
+
- [`@hua-labs/hua`](https://www.npmjs.com/package/@hua-labs/hua) — UX framework (includes motion)
|
|
79
|
+
|
|
80
|
+
## Requirements
|
|
81
|
+
|
|
82
|
+
React >= 19.0.0 · React DOM >= 19.0.0 · TypeScript >= 5.9
|
|
83
|
+
|
|
84
|
+
## License
|
|
85
|
+
|
|
86
|
+
MIT — [HUA Labs](https://github.com/HUA-Labs/HUA-Labs-public)
|
package/dist/index.d.mts
CHANGED
|
@@ -680,7 +680,7 @@ declare function useSmartMotion<T extends HTMLElement = HTMLDivElement>(options?
|
|
|
680
680
|
interface UseUnifiedMotionOptions extends Omit<BaseMotionOptions, 'autoStart'> {
|
|
681
681
|
/** Motion type to use */
|
|
682
682
|
type: EntranceType;
|
|
683
|
-
/** Auto start animation @default
|
|
683
|
+
/** Auto start animation @default true */
|
|
684
684
|
autoStart?: boolean;
|
|
685
685
|
/** Slide distance (px) for slide types @default 50 */
|
|
686
686
|
distance?: number;
|
package/dist/index.d.ts
CHANGED
|
@@ -680,7 +680,7 @@ declare function useSmartMotion<T extends HTMLElement = HTMLDivElement>(options?
|
|
|
680
680
|
interface UseUnifiedMotionOptions extends Omit<BaseMotionOptions, 'autoStart'> {
|
|
681
681
|
/** Motion type to use */
|
|
682
682
|
type: EntranceType;
|
|
683
|
-
/** Auto start animation @default
|
|
683
|
+
/** Auto start animation @default true */
|
|
684
684
|
autoStart?: boolean;
|
|
685
685
|
/** Slide distance (px) for slide types @default 50 */
|
|
686
686
|
distance?: number;
|