aniview 1.0.0 → 1.1.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 +40 -21
- package/README.md +93 -97
- package/dist/Aniview.d.ts +1 -0
- package/dist/Aniview.d.ts.map +1 -1
- package/dist/Aniview.js +24 -682
- package/dist/Aniview.js.map +1 -1
- package/dist/AniviewPanel.d.ts.map +1 -1
- package/dist/aniviewConfig.d.ts +98 -6
- package/dist/aniviewConfig.d.ts.map +1 -1
- package/dist/aniviewConfig.js +109 -338
- package/dist/aniviewConfig.js.map +1 -1
- package/dist/aniviewProvider.d.ts +3 -1
- package/dist/aniviewProvider.d.ts.map +1 -1
- package/dist/aniviewProvider.js +24 -5
- package/dist/aniviewProvider.js.map +1 -1
- package/dist/core/AniviewBake.d.ts +37 -0
- package/dist/core/AniviewBake.d.ts.map +1 -0
- package/dist/core/AniviewBake.js +309 -0
- package/dist/core/AniviewBake.js.map +1 -0
- package/dist/core/AniviewColor.d.ts +62 -0
- package/dist/core/AniviewColor.d.ts.map +1 -0
- package/dist/core/AniviewColor.js +199 -0
- package/dist/core/AniviewColor.js.map +1 -0
- package/dist/core/AniviewGesture.d.ts +46 -0
- package/dist/core/AniviewGesture.d.ts.map +1 -0
- package/dist/core/AniviewGesture.js +344 -0
- package/dist/core/AniviewGesture.js.map +1 -0
- package/dist/core/AniviewLock.d.ts +8 -0
- package/dist/core/AniviewLock.d.ts.map +1 -1
- package/dist/core/AniviewLock.js +8 -0
- package/dist/core/AniviewLock.js.map +1 -1
- package/dist/core/AniviewMath.d.ts +31 -7
- package/dist/core/AniviewMath.d.ts.map +1 -1
- package/dist/core/AniviewMath.js +31 -7
- package/dist/core/AniviewMath.js.map +1 -1
- package/dist/core/AniviewStyle.d.ts +34 -0
- package/dist/core/AniviewStyle.d.ts.map +1 -0
- package/dist/core/AniviewStyle.js +333 -0
- package/dist/core/AniviewStyle.js.map +1 -0
- package/dist/core/AniviewStyleUtils.d.ts +157 -0
- package/dist/core/AniviewStyleUtils.d.ts.map +1 -0
- package/dist/core/AniviewStyleUtils.js +44 -0
- package/dist/core/AniviewStyleUtils.js.map +1 -0
- package/dist/useAniview.js +2 -0
- package/dist/useAniview.js.map +1 -1
- package/dist/useAniviewContext.d.ts +75 -1
- package/dist/useAniviewContext.d.ts.map +1 -1
- package/dist/useAniviewContext.js.map +1 -1
- package/dist/useAniviewLock.d.ts +2 -5
- package/dist/useAniviewLock.d.ts.map +1 -1
- package/dist/useAniviewLock.js +13 -5
- package/dist/useAniviewLock.js.map +1 -1
- package/package.json +7 -6
- package/src/Aniview.tsx +43 -704
- package/src/__tests__/AniviewBake.test.ts +282 -0
- package/src/__tests__/AniviewColor.test.ts +431 -0
- package/src/__tests__/AniviewSnapshot.test.tsx +30 -33
- package/src/__tests__/__snapshots__/AniviewSnapshot.test.tsx.snap +183 -3
- package/src/aniviewConfig.tsx +115 -363
- package/src/aniviewProvider.tsx +29 -9
- package/src/core/AniviewBake.ts +310 -0
- package/src/core/AniviewColor.ts +219 -0
- package/src/core/AniviewGesture.ts +433 -0
- package/src/core/AniviewLock.ts +31 -23
- package/src/core/AniviewMath.ts +31 -7
- package/src/core/AniviewStyle.ts +400 -0
- package/src/core/AniviewStyleUtils.ts +49 -0
- package/src/useAniview.tsx +2 -0
- package/src/useAniviewContext.tsx +75 -3
- package/src/useAniviewLock.tsx +14 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,21 +1,40 @@
|
|
|
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.
|
|
9
|
-
|
|
10
|
-
### Added
|
|
11
|
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
-
|
|
19
|
-
-
|
|
20
|
-
-
|
|
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.1] - 2026-06-09
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- Core animation baking, color interpolation, gesture, and style helpers split into focused modules under `src/core/`.
|
|
13
|
+
- Regression tests for frame baking, color interpolation, lock masks, math helpers, and snapshots.
|
|
14
|
+
- Local development guide for testing Aniview from a consumer React Native app with Metro module de-duplication.
|
|
15
|
+
|
|
16
|
+
### Changed
|
|
17
|
+
|
|
18
|
+
- Refreshed README, Getting Started, Core Concepts, API Reference, Performance, Testing, Gesture Control, Reporting Issues, and Docusaurus docs to match the current public API.
|
|
19
|
+
- Updated development dependencies for the current React Native/Reanimated test setup.
|
|
20
|
+
- Improved snapshot test setup for the current React test renderer behavior.
|
|
21
|
+
- Clarified `persistent` component mounting versus `eventPersistent` event-frame weighting.
|
|
22
|
+
|
|
23
|
+
### Fixed
|
|
24
|
+
|
|
25
|
+
- Corrected directional lock-mask handling so `AniviewLock.mask({ left, right, up, down })` matches provider gesture behavior.
|
|
26
|
+
- Removed stale Docusaurus/template documentation language and broken documentation links.
|
|
27
|
+
|
|
28
|
+
## [1.0.0] - 2026-02-10
|
|
29
|
+
|
|
30
|
+
### Added
|
|
31
|
+
|
|
32
|
+
- `Aniview` — core animated component with spatial and event-driven keyframes
|
|
33
|
+
- `AniviewProvider` — context provider with gesture handling and spring physics
|
|
34
|
+
- `AniviewConfig` — 2D grid layout engine with page mapping, overlaps, and adjacency graphs
|
|
35
|
+
- `useAniview` — hook to access Aniview context (dimensions, events, config)
|
|
36
|
+
- `useAniviewLock` — hook for directional gesture locking
|
|
37
|
+
- Smart color interpolation (transparent-aware, no gray artifacts)
|
|
38
|
+
- Pre-computed animation grid (zero runtime frame searches)
|
|
39
|
+
- Worklet-optimized rendering (UI thread only)
|
|
40
|
+
- Full TypeScript type definitions
|
package/README.md
CHANGED
|
@@ -4,127 +4,123 @@
|
|
|
4
4
|
[](LICENSE)
|
|
5
5
|
[](https://reactnative.dev/)
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Aniview is a coordinate-based animation and page-navigation engine for React Native. It lets you describe a 2D page world, place components on named pages, and define style frames that interpolate as the camera moves between pages or as custom Reanimated `SharedValue`s change.
|
|
8
8
|
|
|
9
|
-
##
|
|
9
|
+
## What it is good for
|
|
10
10
|
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
- **2D Layout Engine** - Grid-based page navigation with overlap support
|
|
17
|
-
- **TypeScript First** - Full type safety out of the box
|
|
11
|
+
- Swipeable multi-page interfaces that are not just a flat carousel.
|
|
12
|
+
- Components that morph between pages without imperative animation code.
|
|
13
|
+
- Event-driven effects such as scroll, zoom, or progress-linked animation.
|
|
14
|
+
- React Native apps that need gesture coordination between page swipes and nested interactions.
|
|
15
|
+
- Persistent animated surfaces such as video, canvas, or GL content that must not unmount offscreen.
|
|
18
16
|
|
|
19
|
-
##
|
|
17
|
+
## Install
|
|
18
|
+
|
|
19
|
+
Aniview expects a working React Native app with Reanimated and React Native Gesture Handler configured.
|
|
20
20
|
|
|
21
21
|
```bash
|
|
22
22
|
npm install aniview react-native-reanimated react-native-gesture-handler
|
|
23
23
|
```
|
|
24
24
|
|
|
25
|
-
|
|
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
|
-
}
|
|
25
|
+
For Expo projects, prefer Expo's version resolver for the peer dependencies:
|
|
50
26
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
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
|
-
}
|
|
27
|
+
```bash
|
|
28
|
+
npx expo install react-native-reanimated react-native-gesture-handler
|
|
29
|
+
npm install aniview
|
|
68
30
|
```
|
|
69
31
|
|
|
70
|
-
|
|
32
|
+
Make sure the Reanimated Babel plugin is configured according to the Reanimated docs for your app.
|
|
71
33
|
|
|
72
|
-
|
|
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
|
|
34
|
+
## Minimal Example
|
|
81
35
|
|
|
82
|
-
|
|
36
|
+
```tsx
|
|
37
|
+
import React from "react";
|
|
38
|
+
import { Text, StyleSheet } from "react-native";
|
|
39
|
+
import { GestureHandlerRootView } from "react-native-gesture-handler";
|
|
40
|
+
import { Aniview, AniviewProvider } from "aniview";
|
|
83
41
|
|
|
84
|
-
|
|
42
|
+
const pageMap = {
|
|
43
|
+
HOME: 0,
|
|
44
|
+
PROFILE: 1,
|
|
45
|
+
};
|
|
85
46
|
|
|
86
|
-
|
|
47
|
+
export default function App() {
|
|
48
|
+
return (
|
|
49
|
+
<GestureHandlerRootView style={styles.root}>
|
|
50
|
+
<AniviewProvider layout={[[1, 1]]} pageMap={pageMap} defaultPage="HOME">
|
|
51
|
+
<Aniview pageId="HOME" style={[styles.page, styles.home]}>
|
|
52
|
+
<Text style={styles.title}>Home</Text>
|
|
53
|
+
</Aniview>
|
|
54
|
+
|
|
55
|
+
<Aniview pageId="PROFILE" style={[styles.page, styles.profile]}>
|
|
56
|
+
<Text style={styles.title}>Profile</Text>
|
|
57
|
+
</Aniview>
|
|
58
|
+
|
|
59
|
+
<Aniview
|
|
60
|
+
pageId="HOME"
|
|
61
|
+
style={styles.badge}
|
|
62
|
+
frames={{
|
|
63
|
+
atProfile: {
|
|
64
|
+
page: "PROFILE",
|
|
65
|
+
style: {
|
|
66
|
+
backgroundColor: "#e91e63",
|
|
67
|
+
transform: [{ scale: 1.4 }],
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
}}
|
|
71
|
+
/>
|
|
72
|
+
</AniviewProvider>
|
|
73
|
+
</GestureHandlerRootView>
|
|
74
|
+
);
|
|
75
|
+
}
|
|
87
76
|
|
|
77
|
+
const styles = StyleSheet.create({
|
|
78
|
+
root: { flex: 1 },
|
|
79
|
+
page: {
|
|
80
|
+
width: "100%",
|
|
81
|
+
height: "100%",
|
|
82
|
+
alignItems: "center",
|
|
83
|
+
justifyContent: "center",
|
|
84
|
+
},
|
|
85
|
+
home: { backgroundColor: "#e3f2fd" },
|
|
86
|
+
profile: { backgroundColor: "#fce4ec" },
|
|
87
|
+
title: { fontSize: 32, fontWeight: "700" },
|
|
88
|
+
badge: {
|
|
89
|
+
width: 72,
|
|
90
|
+
height: 72,
|
|
91
|
+
borderRadius: 36,
|
|
92
|
+
backgroundColor: "#2196f3",
|
|
93
|
+
left: 32,
|
|
94
|
+
top: 64,
|
|
95
|
+
},
|
|
96
|
+
});
|
|
88
97
|
```
|
|
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
98
|
|
|
97
|
-
|
|
98
|
-
2. **Event-Driven Animations** - Triggered by custom SharedValues (scroll, zoom, etc.)
|
|
99
|
+
Swipe horizontally to move between `HOME` and `PROFILE`. The badge belongs to `HOME`, but its frame describes how it should look when the camera reaches `PROFILE`.
|
|
99
100
|
|
|
100
|
-
|
|
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
|
|
101
|
+
## Documentation
|
|
108
102
|
|
|
109
|
-
|
|
103
|
+
- [Getting Started](docs/01-getting-started.md) - Installation and first working app
|
|
104
|
+
- [Core Concepts](docs/02-core-concepts.md) - Coordinate space, pages, frames, baking, and virtualization
|
|
105
|
+
- [API Reference](docs/03-api-reference.md) - Public components, hooks, methods, and types
|
|
106
|
+
- [Advanced Patterns](docs/04-advanced-patterns.md) - Composition, persistence, and event-driven patterns
|
|
107
|
+
- [Examples & Recipes](docs/05-examples.md) - Larger examples and interaction recipes
|
|
108
|
+
- [Performance Guide](docs/06-performance.md) - Optimization techniques
|
|
109
|
+
- [Testing](docs/07-testing.md) - Testing Aniview logic and components
|
|
110
|
+
- [Gesture Control](docs/08-gesture-control.md) - Gesture toggles, locks, and simultaneous handlers
|
|
111
|
+
- [Reporting Issues](docs/09-reporting-issues.md) - Bug reports and feature requests
|
|
112
|
+
- [Local Development](LOCAL_DEV.md) - Using a local checkout from a React Native app
|
|
110
113
|
|
|
111
|
-
|
|
114
|
+
## Mental Model
|
|
112
115
|
|
|
113
|
-
|
|
114
|
-
- **React Native CLI** projects
|
|
115
|
-
- **New Architecture** (Fabric) — fully compatible (pure JS/TS + Reanimated worklets)
|
|
116
|
+
Aniview has three moving parts:
|
|
116
117
|
|
|
117
|
-
|
|
118
|
+
1. `AniviewProvider` owns the camera, dimensions, page layout, gesture handler, and custom event shared values.
|
|
119
|
+
2. `AniviewConfig` maps page IDs to world coordinates and builds gesture/navigation rules.
|
|
120
|
+
3. `Aniview` components declare a home page plus optional spatial or event frames. On mount, frames are baked into interpolation lanes consumed by Reanimated worklets.
|
|
118
121
|
|
|
119
|
-
|
|
122
|
+
The important composition rule: use sibling `Aniview` components for world-positioned elements. Nest `Aniview` components only when you intentionally want parent and child transforms to combine.
|
|
120
123
|
|
|
121
124
|
## License
|
|
122
125
|
|
|
123
|
-
MIT
|
|
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)
|
|
126
|
+
MIT (c) Madelyn Cruz Tan (TitanicEclair)
|
package/dist/Aniview.d.ts
CHANGED
|
@@ -40,6 +40,7 @@ import { AniviewProps } from './useAniviewContext';
|
|
|
40
40
|
* @param props.persistent - If `true`, stays mounted even when far offscreen. Required for WebGL/Three.js canvases. Default: `false`
|
|
41
41
|
* @param props.style - Base styles applied when at home position. Numeric and color props here become the interpolation baseline.
|
|
42
42
|
* @param props.pointerEvents - Standard RN pointer events. Useful for overlay pages that shouldn't block touches.
|
|
43
|
+
* @returns Animated view that interpolates styles from spatial and event lanes.
|
|
43
44
|
*
|
|
44
45
|
* @example
|
|
45
46
|
* ```tsx
|
package/dist/Aniview.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Aniview.d.ts","sourceRoot":"","sources":["../src/Aniview.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoD,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"Aniview.d.ts","sourceRoot":"","sources":["../src/Aniview.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoD,MAAM,OAAO,CAAC;AAOzE,OAAO,EAAE,YAAY,EAAe,MAAM,qBAAqB,CAAC;AAKhE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2DG;AACH,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,KAAK,EAAE,YAAY,4BAsIlD"}
|