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
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { SharedValue, AnimatedProps, WithSpringConfig } from "react-native-reanimated";
|
|
3
|
+
import { ViewProps, ViewStyle } from "react-native";
|
|
4
|
+
import { WorldBounds } from "./core/AniviewMath";
|
|
5
|
+
export type { WorldBounds };
|
|
6
|
+
/**
|
|
7
|
+
* ANIVIEW DOMAIN TYPES
|
|
8
|
+
*/
|
|
9
|
+
export interface AniviewFrame {
|
|
10
|
+
/** Target page ID for spatial transitions (can be numeric index or semantic name) */
|
|
11
|
+
page?: number | string;
|
|
12
|
+
/** Custom event name for state-driven transitions (e.g., 'zoom', 'tilt') */
|
|
13
|
+
event?: string;
|
|
14
|
+
/** The value of the event driver that triggers this frame */
|
|
15
|
+
value?: number;
|
|
16
|
+
/** Style overrides for this frame */
|
|
17
|
+
style?: ViewStyle | ViewStyle[];
|
|
18
|
+
/**
|
|
19
|
+
* If true, this event-driven frame remains active across all pages.
|
|
20
|
+
* If false (default), the effect is modulated by proximity to the component's home page.
|
|
21
|
+
*/
|
|
22
|
+
persistent?: boolean;
|
|
23
|
+
/** Optional opacity override shortcut */
|
|
24
|
+
opacity?: number;
|
|
25
|
+
/** Optional scale override shortcut */
|
|
26
|
+
scale?: number;
|
|
27
|
+
/** Optional rotate (Z) override shortcut (degrees) */
|
|
28
|
+
rotate?: number;
|
|
29
|
+
/** Spring config override for this specific frame transition (future) */
|
|
30
|
+
springConfig?: any;
|
|
31
|
+
}
|
|
32
|
+
export interface BakedFrame extends AniviewFrame {
|
|
33
|
+
worldX: number;
|
|
34
|
+
worldY: number;
|
|
35
|
+
}
|
|
36
|
+
export interface AniviewRegistration {
|
|
37
|
+
offset: {
|
|
38
|
+
x: number;
|
|
39
|
+
y: number;
|
|
40
|
+
};
|
|
41
|
+
dimensions: {
|
|
42
|
+
width: number;
|
|
43
|
+
height: number;
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
export interface AniviewProps extends AnimatedProps<ViewProps> {
|
|
47
|
+
pageId: number | string;
|
|
48
|
+
frames?: AniviewFrame[] | Record<string, AniviewFrame>;
|
|
49
|
+
events?: {
|
|
50
|
+
x: SharedValue<number>;
|
|
51
|
+
y: SharedValue<number>;
|
|
52
|
+
[key: string]: SharedValue<number>;
|
|
53
|
+
} | null;
|
|
54
|
+
children?: React.ReactNode;
|
|
55
|
+
style?: ViewStyle | ViewStyle[];
|
|
56
|
+
pointerEvents?: 'box-none' | 'none' | 'box-only' | 'auto';
|
|
57
|
+
/**
|
|
58
|
+
* If true, this component stays mounted even when offscreen.
|
|
59
|
+
* Essential for 3D/GL contexts.
|
|
60
|
+
* If false (default), it unmounts when offscreen to save RAM.
|
|
61
|
+
*/
|
|
62
|
+
persistent?: boolean;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Imperative Handle for controlling the Aniview Physics Engine
|
|
66
|
+
*/
|
|
67
|
+
export interface AniviewHandle {
|
|
68
|
+
/** Programmatically snap to a specific page */
|
|
69
|
+
snapToPage: (pageId: number | string) => void;
|
|
70
|
+
/** Get the current active page ID */
|
|
71
|
+
getCurrentPage: () => number | string;
|
|
72
|
+
/** Lock specific axes (bitmask: 1=Left, 2=Right, 4=Up, 8=Down) */
|
|
73
|
+
lock: (mask: number) => void;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Interface for the Aniview configuration engine.
|
|
77
|
+
*/
|
|
78
|
+
export interface IAniviewConfig {
|
|
79
|
+
/** Gets the global (x, y) offset for a specific page relative to origin. */
|
|
80
|
+
getPageOffset(pageId: number | string, dims: AniviewContextType['dimensions']): {
|
|
81
|
+
x: number;
|
|
82
|
+
y: number;
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* Pre-calculates absolute coordinates for a component's keyframes.
|
|
86
|
+
* Executed during the 'Baking' phase on the JS thread.
|
|
87
|
+
*/
|
|
88
|
+
register(pageId: number | string, dims: AniviewContextType['dimensions'], keyframes?: AniviewFrame[] | Record<string, AniviewFrame>, localLayout?: {
|
|
89
|
+
x: number;
|
|
90
|
+
y: number;
|
|
91
|
+
}): {
|
|
92
|
+
homeOffset: {
|
|
93
|
+
x: number;
|
|
94
|
+
y: number;
|
|
95
|
+
};
|
|
96
|
+
bakedFrames: Record<string, BakedFrame>;
|
|
97
|
+
eventLanes: Record<string, BakedFrame[]>;
|
|
98
|
+
localLayout: {
|
|
99
|
+
x: number;
|
|
100
|
+
y: number;
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
/** Minimal offset context for direct page references */
|
|
104
|
+
registerPage(pageId: number | string, dims: AniviewContextType['dimensions']): AniviewRegistration;
|
|
105
|
+
/** Returns all valid page IDs defined in the layout matrix */
|
|
106
|
+
getPages(): number[];
|
|
107
|
+
/** Map of PageID -> (x, y) coordinates */
|
|
108
|
+
getPagesMap(dims: AniviewContextType['dimensions']): Record<number, {
|
|
109
|
+
x: number;
|
|
110
|
+
y: number;
|
|
111
|
+
}>;
|
|
112
|
+
/** Returns calculated min/max world boundaries for gesture clamping */
|
|
113
|
+
getWorldBounds(dims: AniviewContextType['dimensions']): WorldBounds;
|
|
114
|
+
/** Update dimensions dynamically (used by onLayout) */
|
|
115
|
+
updateDimensions(dims: AniviewContextType['dimensions']): void;
|
|
116
|
+
/** Update spring config dynamically */
|
|
117
|
+
updateSpringConfig(config: WithSpringConfig): void;
|
|
118
|
+
/** Generates the core Pan Gesture logic */
|
|
119
|
+
generateGesture(x: SharedValue<number>, y: SharedValue<number>, onPageChange?: (pageId: number | string) => void, lockMask?: SharedValue<number>, simultaneousHandlers?: any, gestureEnabled?: SharedValue<boolean>, dims?: AniviewContextType['dimensions'], isSnapping?: SharedValue<boolean>, lastTargetId?: SharedValue<number | string>): any;
|
|
120
|
+
/** Resolves a potentially semantic pageId string into its numeric index */
|
|
121
|
+
resolvePageId(pageId: number | string): number;
|
|
122
|
+
/** Returns the current active page ID (SharedValue) */
|
|
123
|
+
getCurrentPage(): SharedValue<number | string>;
|
|
124
|
+
}
|
|
125
|
+
export interface AniviewContextType {
|
|
126
|
+
dimensions: {
|
|
127
|
+
width: number;
|
|
128
|
+
height: number;
|
|
129
|
+
offsetX: number;
|
|
130
|
+
offsetY: number;
|
|
131
|
+
};
|
|
132
|
+
events: {
|
|
133
|
+
x: SharedValue<number>;
|
|
134
|
+
y: SharedValue<number>;
|
|
135
|
+
[key: string]: SharedValue<number>;
|
|
136
|
+
};
|
|
137
|
+
activationMap: Record<number, SharedValue<number>>;
|
|
138
|
+
panGesture: any;
|
|
139
|
+
config: IAniviewConfig;
|
|
140
|
+
/** Programmatically lock specific axes */
|
|
141
|
+
lock: (mask: number) => void;
|
|
142
|
+
/** Set of page IDs that should currently be mounted */
|
|
143
|
+
visiblePages: Set<number>;
|
|
144
|
+
/** Tracks if Aniview is currently snapping/animating toward a page */
|
|
145
|
+
isMoving: SharedValue<boolean>;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* The full logic state for a specific Aniview component.
|
|
149
|
+
*/
|
|
150
|
+
export interface AniviewLogic extends AniviewContextType {
|
|
151
|
+
registration: AniviewRegistration;
|
|
152
|
+
activationValue: SharedValue<number>;
|
|
153
|
+
keyframes: Record<string, AniviewFrame> | undefined;
|
|
154
|
+
}
|
|
155
|
+
export declare const AniviewContext: React.Context<AniviewContextType | null>;
|
|
156
|
+
//# sourceMappingURL=useAniviewContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAniviewContext.d.ts","sourceRoot":"","sources":["../src/useAniviewContext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAwB,MAAM,OAAO,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEvF,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,YAAY,EAAE,WAAW,EAAE,CAAC;AAE5B;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,qFAAqF;IACrF,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,4EAA4E;IAC5E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,6DAA6D;IAC7D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,qCAAqC;IACrC,KAAK,CAAC,EAAE,SAAS,GAAG,SAAS,EAAE,CAAC;IAChC;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,yCAAyC;IACzC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,uCAAuC;IACvC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,sDAAsD;IACtD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,yEAAyE;IACzE,YAAY,CAAC,EAAE,GAAG,CAAC;CACpB;AAED,MAAM,WAAW,UAAW,SAAQ,YAAY;IAC9C,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAA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;IACvB,0CAA0C;IAC1C,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7B,uDAAuD;IACvD,YAAY,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC1B,sEAAsE;IACtE,QAAQ,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;CAChC;AAED;;GAEG;AACH,MAAM,WAAW,YAAa,SAAQ,kBAAkB;IACtD,YAAY,EAAE,mBAAmB,CAAC;IAClC,eAAe,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACrC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,GAAG,SAAS,CAAC;CACrD;AAED,eAAO,MAAM,cAAc,0CAAiD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAniviewContext.js","sourceRoot":"","sources":["../src/useAniviewContext.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAyK7C,MAAM,CAAC,MAAM,cAAc,GAAG,aAAa,CAA4B,IAAI,CAAC,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { AniviewLock, AniviewAxisLock } from './core/AniviewLock';
|
|
2
|
+
export { AniviewLock };
|
|
3
|
+
export type { AniviewAxisLock };
|
|
4
|
+
/**
|
|
5
|
+
* Hook to lock/unlock Aniview swipe gestures from within a child component.
|
|
6
|
+
* Provides a clean API for disabling specific directions.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* const { lockDirections } = useAniviewLock();
|
|
10
|
+
* lockDirections({ left: true }); // Prevent swiping left
|
|
11
|
+
*/
|
|
12
|
+
export declare function useAniviewLock(): {
|
|
13
|
+
lockDirections: (directions: AniviewAxisLock) => void;
|
|
14
|
+
unlock: () => void;
|
|
15
|
+
isMoving: import("react-native-reanimated").SharedValue<boolean> | undefined;
|
|
16
|
+
AniviewLock: {
|
|
17
|
+
mask: (directions: AniviewAxisLock) => number;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=useAniviewLock.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAniviewLock.d.ts","sourceRoot":"","sources":["../src/useAniviewLock.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAElE,OAAO,EAAE,WAAW,EAAE,CAAC;AACvB,YAAY,EAAE,eAAe,EAAE,CAAC;AAEhC;;;;;;;GAOG;AACH,wBAAgB,cAAc;iCAGU,eAAe;;;;;;EAkBtD"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { useContext } from 'react';
|
|
2
|
+
import { AniviewContext } from './useAniviewContext';
|
|
3
|
+
import { AniviewLock } from './core/AniviewLock';
|
|
4
|
+
export { AniviewLock };
|
|
5
|
+
/**
|
|
6
|
+
* Hook to lock/unlock Aniview swipe gestures from within a child component.
|
|
7
|
+
* Provides a clean API for disabling specific directions.
|
|
8
|
+
*
|
|
9
|
+
* Usage:
|
|
10
|
+
* const { lockDirections } = useAniviewLock();
|
|
11
|
+
* lockDirections({ left: true }); // Prevent swiping left
|
|
12
|
+
*/
|
|
13
|
+
export function useAniviewLock() {
|
|
14
|
+
const context = useContext(AniviewContext);
|
|
15
|
+
const lockDirections = (directions) => {
|
|
16
|
+
if (context) {
|
|
17
|
+
context.lock(AniviewLock.mask(directions));
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
const unlock = () => {
|
|
21
|
+
if (context) {
|
|
22
|
+
context.lock(0);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
return {
|
|
26
|
+
lockDirections,
|
|
27
|
+
unlock,
|
|
28
|
+
isMoving: context?.isMoving,
|
|
29
|
+
AniviewLock // Export helper as well
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=useAniviewLock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAniviewLock.js","sourceRoot":"","sources":["../src/useAniviewLock.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAmB,MAAM,oBAAoB,CAAC;AAElE,OAAO,EAAE,WAAW,EAAE,CAAC;AAGvB;;;;;;;GAOG;AACH,MAAM,UAAU,cAAc;IAC1B,MAAM,OAAO,GAAG,UAAU,CAAC,cAAc,CAAC,CAAC;IAE3C,MAAM,cAAc,GAAG,CAAC,UAA2B,EAAE,EAAE;QACnD,IAAI,OAAO,EAAE,CAAC;YACV,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;QAC/C,CAAC;IACL,CAAC,CAAC;IAEF,MAAM,MAAM,GAAG,GAAG,EAAE;QAChB,IAAI,OAAO,EAAE,CAAC;YACV,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACpB,CAAC;IACL,CAAC,CAAC;IAEF,OAAO;QACH,cAAc;QACd,MAAM;QACN,QAAQ,EAAE,OAAO,EAAE,QAAQ;QAC3B,WAAW,CAAC,wBAAwB;KACvC,CAAC;AACN,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "aniview",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Absolute World Coordinate Animation Engine for React Native",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"module": "dist/index.js",
|
|
8
|
+
"react-native": "src/index.ts",
|
|
9
|
+
"source": "src/index.ts",
|
|
10
|
+
"files": [
|
|
11
|
+
"dist/",
|
|
12
|
+
"src/",
|
|
13
|
+
"README.md",
|
|
14
|
+
"LICENSE",
|
|
15
|
+
"CHANGELOG.md"
|
|
16
|
+
],
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://github.com/TitanicEclair/aniview.git"
|
|
20
|
+
},
|
|
21
|
+
"homepage": "https://github.com/TitanicEclair/aniview#readme",
|
|
22
|
+
"bugs": {
|
|
23
|
+
"url": "https://github.com/TitanicEclair/aniview/issues"
|
|
24
|
+
},
|
|
25
|
+
"keywords": [
|
|
26
|
+
"react-native",
|
|
27
|
+
"animation",
|
|
28
|
+
"gesture",
|
|
29
|
+
"reanimated",
|
|
30
|
+
"page-transition",
|
|
31
|
+
"coordinate-system",
|
|
32
|
+
"worklet",
|
|
33
|
+
"pager"
|
|
34
|
+
],
|
|
35
|
+
"author": "Madelyn Cruz Tan",
|
|
36
|
+
"license": "MIT",
|
|
37
|
+
"scripts": {
|
|
38
|
+
"build": "tsc --project tsconfig.build.json",
|
|
39
|
+
"prepare": "npm run build",
|
|
40
|
+
"lint": "tsc --noEmit",
|
|
41
|
+
"test": "jest"
|
|
42
|
+
},
|
|
43
|
+
"peerDependencies": {
|
|
44
|
+
"react": ">=18.0.0",
|
|
45
|
+
"react-native": ">=0.71.0",
|
|
46
|
+
"react-native-gesture-handler": ">=2.14.0",
|
|
47
|
+
"react-native-reanimated": ">=3.0.0"
|
|
48
|
+
},
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"@types/jest": "29.5.14",
|
|
51
|
+
"@types/react": "~19.1.0",
|
|
52
|
+
"@types/react-test-renderer": "^19.1.0",
|
|
53
|
+
"jest": "~29.7.0",
|
|
54
|
+
"react-native-gesture-handler": "^2.30.0",
|
|
55
|
+
"react-native-reanimated": "^4.2.1",
|
|
56
|
+
"react-test-renderer": "^19.2.4",
|
|
57
|
+
"tsx": "^4.21.0",
|
|
58
|
+
"typescript": "~5.3.0"
|
|
59
|
+
}
|
|
60
|
+
}
|