aniview 1.0.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/CHANGELOG.md +21 -0
- package/LICENSE +21 -0
- package/README.md +130 -0
- package/dist/Aniview.d.ts +63 -0
- package/dist/Aniview.d.ts.map +1 -0
- package/dist/Aniview.js +831 -0
- package/dist/Aniview.js.map +1 -0
- package/dist/AniviewPanel.d.ts +33 -0
- package/dist/AniviewPanel.d.ts.map +1 -0
- package/dist/AniviewPanel.js +66 -0
- package/dist/AniviewPanel.js.map +1 -0
- package/dist/GestureStressTest.d.ts +3 -0
- package/dist/GestureStressTest.d.ts.map +1 -0
- package/dist/GestureStressTest.js +125 -0
- package/dist/GestureStressTest.js.map +1 -0
- package/dist/aniviewConfig.d.ts +175 -0
- package/dist/aniviewConfig.d.ts.map +1 -0
- package/dist/aniviewConfig.js +568 -0
- package/dist/aniviewConfig.js.map +1 -0
- package/dist/aniviewProvider.d.ts +93 -0
- package/dist/aniviewProvider.d.ts.map +1 -0
- package/dist/aniviewProvider.js +229 -0
- package/dist/aniviewProvider.js.map +1 -0
- package/dist/core/AniviewLock.d.ts +16 -0
- package/dist/core/AniviewLock.d.ts.map +1 -0
- package/dist/core/AniviewLock.js +18 -0
- package/dist/core/AniviewLock.js.map +1 -0
- package/dist/core/AniviewMath.d.ts +41 -0
- package/dist/core/AniviewMath.d.ts.map +1 -0
- package/dist/core/AniviewMath.js +69 -0
- package/dist/core/AniviewMath.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/useAniview.d.ts +39 -0
- package/dist/useAniview.d.ts.map +1 -0
- package/dist/useAniview.js +32 -0
- package/dist/useAniview.js.map +1 -0
- package/dist/useAniviewContext.d.ts +156 -0
- package/dist/useAniviewContext.d.ts.map +1 -0
- package/dist/useAniviewContext.js +3 -0
- package/dist/useAniviewContext.js.map +1 -0
- package/dist/useAniviewLock.d.ts +20 -0
- package/dist/useAniviewLock.d.ts.map +1 -0
- package/dist/useAniviewLock.js +32 -0
- package/dist/useAniviewLock.js.map +1 -0
- package/package.json +60 -0
- package/src/Aniview.tsx +868 -0
- package/src/AniviewPanel.tsx +141 -0
- package/src/GestureStressTest.tsx +144 -0
- package/src/__tests__/AniviewLock.test.ts +58 -0
- package/src/__tests__/AniviewMath.test.ts +211 -0
- package/src/__tests__/AniviewSnapshot.test.tsx +85 -0
- package/src/__tests__/__snapshots__/AniviewSnapshot.test.tsx.snap +7 -0
- package/src/__tests__/aniviewConfig.test.ts +70 -0
- package/src/aniviewConfig.tsx +688 -0
- package/src/aniviewProvider.tsx +307 -0
- package/src/core/AniviewLock.ts +23 -0
- package/src/core/AniviewMath.ts +107 -0
- package/src/index.ts +6 -0
- package/src/useAniview.tsx +75 -0
- package/src/useAniviewContext.tsx +170 -0
- package/src/useAniviewLock.tsx +37 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [1.0.0] - 2026-02-10
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- `Aniview` — core animated component with spatial and event-driven keyframes
|
|
13
|
+
- `AniviewProvider` — context provider with gesture handling and spring physics
|
|
14
|
+
- `AniviewConfig` — 2D grid layout engine with page mapping, overlaps, and adjacency graphs
|
|
15
|
+
- `AniviewPanel` / `PanelFrame` — pre-styled panel components
|
|
16
|
+
- `useAniview` — hook to access Aniview context (dimensions, events, config)
|
|
17
|
+
- `useAniviewLock` — hook for directional gesture locking
|
|
18
|
+
- Smart color interpolation (transparent-aware, no gray artifacts)
|
|
19
|
+
- Pre-computed animation grid (zero runtime frame searches)
|
|
20
|
+
- Worklet-optimized rendering (UI thread only)
|
|
21
|
+
- Full TypeScript type definitions
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Madelyn Cruz Tan (TitanicEclair)
|
|
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
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
# Aniview
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/aniview)
|
|
4
|
+
[](LICENSE)
|
|
5
|
+
[](https://reactnative.dev/)
|
|
6
|
+
|
|
7
|
+
> A high-performance, coordinate-based animation engine for React Native. Create fluid, multi-dimensional page transitions with spatial and event-driven animations.
|
|
8
|
+
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
- **Pre-computed Animation Grid** - Zero runtime frame searches
|
|
12
|
+
- **Spatial & Event-Driven** - Animate based on position OR custom events
|
|
13
|
+
- **Gesture Coordination** - Built-in lock system for complex UI interactions
|
|
14
|
+
- **Smart Color Interpolation** - Transparent-aware color transitions
|
|
15
|
+
- **Worklet-Optimized** - Runs entirely on the UI thread
|
|
16
|
+
- **2D Layout Engine** - Grid-based page navigation with overlap support
|
|
17
|
+
- **TypeScript First** - Full type safety out of the box
|
|
18
|
+
|
|
19
|
+
## Quick Start
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm install aniview react-native-reanimated react-native-gesture-handler
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Basic Example
|
|
26
|
+
|
|
27
|
+
```tsx
|
|
28
|
+
import { AniviewProvider, Aniview } from "aniview";
|
|
29
|
+
|
|
30
|
+
// 1. Define your layout (3x3 grid)
|
|
31
|
+
const config = new AniviewConfig(
|
|
32
|
+
[
|
|
33
|
+
[1, 1, 1],
|
|
34
|
+
[1, 1, 1],
|
|
35
|
+
[1, 1, 1],
|
|
36
|
+
],
|
|
37
|
+
0, // default page
|
|
38
|
+
{ HOME: 0, PROFILE: 1, SETTINGS: 2 }, // page map
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
// 2. Wrap your app
|
|
42
|
+
function App() {
|
|
43
|
+
return (
|
|
44
|
+
<AniviewProvider config={config}>
|
|
45
|
+
<Header />
|
|
46
|
+
<Content />
|
|
47
|
+
</AniviewProvider>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// 3. Animate components
|
|
52
|
+
function Header() {
|
|
53
|
+
return (
|
|
54
|
+
<Aniview
|
|
55
|
+
pageId="HOME"
|
|
56
|
+
frames={{
|
|
57
|
+
profile: {
|
|
58
|
+
page: "PROFILE",
|
|
59
|
+
style: { backgroundColor: "blue" },
|
|
60
|
+
},
|
|
61
|
+
}}
|
|
62
|
+
style={{ height: 100, backgroundColor: "white" }}
|
|
63
|
+
>
|
|
64
|
+
<Text>My Header</Text>
|
|
65
|
+
</Aniview>
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Documentation
|
|
71
|
+
|
|
72
|
+
- **[Getting Started](docs/01-getting-started.md)** - Installation and first steps
|
|
73
|
+
- **[Core Concepts](docs/02-core-concepts.md)** - Understanding the architecture
|
|
74
|
+
- **[API Reference](docs/03-api-reference.md)** - Complete API documentation
|
|
75
|
+
- **[Advanced Patterns](docs/04-advanced-patterns.md)** - Composition, Persistence & Virtualization
|
|
76
|
+
- **[Examples & Recipes](docs/05-examples.md)** - Full Example App Walkthrough
|
|
77
|
+
- **[Performance Guide](docs/06-performance.md)** - Optimization techniques
|
|
78
|
+
- **[Testing](docs/07-testing.md)** - How to test Aniview components
|
|
79
|
+
- **[Gesture Control](docs/08-gesture-control.md)** - Lock system and gesture coordination
|
|
80
|
+
- **[Reporting Issues](docs/09-reporting-issues.md)** - Bug reports and feature requests
|
|
81
|
+
|
|
82
|
+
## Key Concepts
|
|
83
|
+
|
|
84
|
+
### The Grid System
|
|
85
|
+
|
|
86
|
+
Aniview uses a **2D grid layout** where each cell represents a "page":
|
|
87
|
+
|
|
88
|
+
```
|
|
89
|
+
[0, 1, 2] → Pages 0, 1, 2 (horizontal row)
|
|
90
|
+
[3, 4, 5] → Pages 3, 4, 5 (second row)
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Components declare where they "live" (`pageId`) and how they transform when navigating to other pages (`frames`).
|
|
94
|
+
|
|
95
|
+
### Animation Types
|
|
96
|
+
|
|
97
|
+
1. **Spatial Animations** - Triggered by page navigation (X/Y position)
|
|
98
|
+
2. **Event-Driven Animations** - Triggered by custom SharedValues (scroll, zoom, etc.)
|
|
99
|
+
|
|
100
|
+
### The Baking Process
|
|
101
|
+
|
|
102
|
+
On mount, Aniview:
|
|
103
|
+
|
|
104
|
+
1. Pre-computes a **grid of all possible states**
|
|
105
|
+
2. Organizes them into **horizontal and vertical lanes**
|
|
106
|
+
3. Marks **constant values** to skip interpolation
|
|
107
|
+
4. All this happens **once**, not on every frame
|
|
108
|
+
|
|
109
|
+
## Platform Support
|
|
110
|
+
|
|
111
|
+
Aniview is designed for **React Native** (iOS and Android). It is compatible with:
|
|
112
|
+
|
|
113
|
+
- **Expo** managed workflow (SDK 49+)
|
|
114
|
+
- **React Native CLI** projects
|
|
115
|
+
- **New Architecture** (Fabric) — fully compatible (pure JS/TS + Reanimated worklets)
|
|
116
|
+
|
|
117
|
+
## Contributing
|
|
118
|
+
|
|
119
|
+
We welcome contributions! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for details.
|
|
120
|
+
|
|
121
|
+
## License
|
|
122
|
+
|
|
123
|
+
MIT © Madelyn Cruz Tan
|
|
124
|
+
|
|
125
|
+
## Credits
|
|
126
|
+
|
|
127
|
+
Built with:
|
|
128
|
+
|
|
129
|
+
- [react-native-reanimated](https://github.com/software-mansion/react-native-reanimated)
|
|
130
|
+
- [react-native-gesture-handler](https://github.com/software-mansion/react-native-gesture-handler)
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { AniviewProps } from './useAniviewContext';
|
|
3
|
+
/**
|
|
4
|
+
* **Aniview** — Absolute World Coordinate Animation Engine Component
|
|
5
|
+
*
|
|
6
|
+
* The core animated view that interpolates its style properties based on
|
|
7
|
+
* the camera's position in a virtual 2D world coordinate system. Each
|
|
8
|
+
* `Aniview` belongs to a specific `pageId` (its "home page") and defines
|
|
9
|
+
* `frames` — keyframes that describe how the component should look when
|
|
10
|
+
* the camera is at a different page or when a custom event reaches a
|
|
11
|
+
* certain value.
|
|
12
|
+
*
|
|
13
|
+
* ### How it works (the "Baking" pipeline)
|
|
14
|
+
*
|
|
15
|
+
* 1. On mount (or when `frames`/`style`/`dimensions` change), Aniview
|
|
16
|
+
* runs a one-time **bake** on the JS thread. This pre-computes a
|
|
17
|
+
* lookup grid of style values indexed by world coordinates.
|
|
18
|
+
* 2. On every frame, `useAnimatedStyle` reads the camera SharedValues
|
|
19
|
+
* (`events.x`, `events.y`) and performs O(1) segment lookups +
|
|
20
|
+
* linear/color interpolation — no searching, no string parsing.
|
|
21
|
+
* 3. The baked data also powers **native virtualization**: components
|
|
22
|
+
* farther than 1.5× screen width from the camera are hidden via
|
|
23
|
+
* `opacity: 0`, keeping the render tree lightweight.
|
|
24
|
+
*
|
|
25
|
+
* ### Key design choices
|
|
26
|
+
*
|
|
27
|
+
* - **Absolute positioning**: All Aniview children are rendered with
|
|
28
|
+
* `position: 'absolute'` and placed via `translateX`/`translateY`
|
|
29
|
+
* relative to the camera. This decouples layout from animation.
|
|
30
|
+
* - **Smart color interpolation**: When transitioning to/from
|
|
31
|
+
* `transparent`, the RGB of the non-transparent color is preserved
|
|
32
|
+
* to avoid grey flash artifacts.
|
|
33
|
+
* - **Selective unmounting**: Non-persistent components unmount when
|
|
34
|
+
* offscreen (after snapping completes) to reclaim memory. Set
|
|
35
|
+
* `persistent={true}` for 3D/GL content that must stay mounted.
|
|
36
|
+
*
|
|
37
|
+
* @param props Standard `ViewProps` plus:
|
|
38
|
+
* @param props.pageId - The page this component belongs to (numeric index or semantic name from `pageMap`)
|
|
39
|
+
* @param props.frames - Keyframe definitions. Object keys are frame names, values are {@link AniviewFrame}
|
|
40
|
+
* @param props.persistent - If `true`, stays mounted even when far offscreen. Required for WebGL/Three.js canvases. Default: `false`
|
|
41
|
+
* @param props.style - Base styles applied when at home position. Numeric and color props here become the interpolation baseline.
|
|
42
|
+
* @param props.pointerEvents - Standard RN pointer events. Useful for overlay pages that shouldn't block touches.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```tsx
|
|
46
|
+
* <Aniview
|
|
47
|
+
* pageId="HOME"
|
|
48
|
+
* style={{ width: '100%', height: '100%', backgroundColor: '#fff' }}
|
|
49
|
+
* frames={{
|
|
50
|
+
* away: { page: 'SETTINGS', opacity: 0 },
|
|
51
|
+
* scrolled: { event: 'scrollY', value: 100, style: { transform: [{ translateY: -50 }] } },
|
|
52
|
+
* }}
|
|
53
|
+
* >
|
|
54
|
+
* <HomeContent />
|
|
55
|
+
* </Aniview>
|
|
56
|
+
* ```
|
|
57
|
+
*
|
|
58
|
+
* @see {@link AniviewProvider} for setting up the coordinate system
|
|
59
|
+
* @see {@link AniviewConfig} for layout and gesture configuration
|
|
60
|
+
* @see {@link useAniview} for accessing context from child components
|
|
61
|
+
*/
|
|
62
|
+
export default function Aniview(props: AniviewProps): React.JSX.Element | null;
|
|
63
|
+
//# sourceMappingURL=Aniview.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Aniview.d.ts","sourceRoot":"","sources":["../src/Aniview.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoD,MAAM,OAAO,CAAC;AAUzE,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAiMnD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DG;AACH,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,KAAK,EAAE,YAAY,4BA6lBlD"}
|