@capgo/capacitor-transitions 8.0.1
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 +583 -0
- package/dist/chunk-RLOQDT3I.mjs +2248 -0
- package/dist/chunk-RLOQDT3I.mjs.map +1 -0
- package/dist/components-6C46YYFQ.mjs +15 -0
- package/dist/components-6C46YYFQ.mjs.map +1 -0
- package/dist/index.d.mts +734 -0
- package/dist/index.d.ts +734 -0
- package/dist/index.js +2400 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +75 -0
- package/dist/index.mjs.map +1 -0
- package/dist/react/index.d.mts +400 -0
- package/dist/react/index.d.ts +400 -0
- package/dist/react/index.js +2244 -0
- package/dist/react/index.js.map +1 -0
- package/dist/react/index.mjs +2210 -0
- package/dist/react/index.mjs.map +1 -0
- package/dist/solid/index.d.mts +288 -0
- package/dist/solid/index.d.ts +288 -0
- package/dist/solid/index.js +2244 -0
- package/dist/solid/index.js.map +1 -0
- package/dist/solid/index.mjs +2210 -0
- package/dist/solid/index.mjs.map +1 -0
- package/dist/svelte/index.d.mts +298 -0
- package/dist/svelte/index.d.ts +298 -0
- package/dist/svelte/index.js +2274 -0
- package/dist/svelte/index.js.map +1 -0
- package/dist/svelte/index.mjs +2239 -0
- package/dist/svelte/index.mjs.map +1 -0
- package/dist/vue/index.d.mts +335 -0
- package/dist/vue/index.d.ts +335 -0
- package/dist/vue/index.js +2244 -0
- package/dist/vue/index.js.map +1 -0
- package/dist/vue/index.mjs +2210 -0
- package/dist/vue/index.mjs.map +1 -0
- package/package.json +127 -0
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core types for @capgo/capacitor-transitions
|
|
3
|
+
* Framework-agnostic page transitions for Capacitor apps
|
|
4
|
+
*/
|
|
5
|
+
/** Direction of the navigation transition */
|
|
6
|
+
type TransitionDirection = 'forward' | 'back' | 'root' | 'none';
|
|
7
|
+
/** Platform-specific animation styles */
|
|
8
|
+
type TransitionPlatform = 'ios' | 'android' | 'auto';
|
|
9
|
+
/** Whether the edge swipe-back gesture is enabled, disabled, or native-detected */
|
|
10
|
+
type SwipeGestureOption = boolean | 'auto';
|
|
11
|
+
/** Which parts of the page to animate */
|
|
12
|
+
type TransitionTarget = 'header' | 'content' | 'footer' | 'all';
|
|
13
|
+
/** Animation easing presets */
|
|
14
|
+
type TransitionEasing = 'linear' | 'ease' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'ios' | 'android' | string;
|
|
15
|
+
/** Configuration for a single transition animation */
|
|
16
|
+
interface TransitionConfig {
|
|
17
|
+
/** Duration in milliseconds (default: 540 for iOS, 280/200 for Android forward/back) */
|
|
18
|
+
duration?: number;
|
|
19
|
+
/** Easing function (default: 'ios' or 'android' based on platform) */
|
|
20
|
+
easing?: TransitionEasing;
|
|
21
|
+
/** Direction of transition */
|
|
22
|
+
direction?: TransitionDirection;
|
|
23
|
+
/** Which elements to animate (default: 'all') */
|
|
24
|
+
targets?: TransitionTarget[];
|
|
25
|
+
/** Custom animation keyframes for entering element */
|
|
26
|
+
enterKeyframes?: Keyframe[];
|
|
27
|
+
/** Custom animation keyframes for leaving element */
|
|
28
|
+
leaveKeyframes?: Keyframe[];
|
|
29
|
+
/** Callback before animation starts */
|
|
30
|
+
onStart?: () => void;
|
|
31
|
+
/** Callback after animation completes */
|
|
32
|
+
onComplete?: () => void;
|
|
33
|
+
/** Whether to use View Transitions API when available (default: false) */
|
|
34
|
+
useViewTransitions?: boolean;
|
|
35
|
+
}
|
|
36
|
+
/** Resolved platform type (excludes 'auto') */
|
|
37
|
+
type ResolvedPlatform = 'ios' | 'android';
|
|
38
|
+
/** Global configuration for the transition system */
|
|
39
|
+
interface TransitionGlobalConfig {
|
|
40
|
+
/** Default platform style (default: 'auto') */
|
|
41
|
+
platform?: TransitionPlatform;
|
|
42
|
+
/** Default duration in ms */
|
|
43
|
+
duration?: number;
|
|
44
|
+
/** Default easing */
|
|
45
|
+
easing?: TransitionEasing;
|
|
46
|
+
/** Whether to use View Transitions API (default: false) */
|
|
47
|
+
useViewTransitions?: boolean;
|
|
48
|
+
/** Custom platform detection function */
|
|
49
|
+
detectPlatform?: () => ResolvedPlatform;
|
|
50
|
+
}
|
|
51
|
+
/** State of a page in the navigation stack */
|
|
52
|
+
interface PageState {
|
|
53
|
+
/** Unique identifier for the page */
|
|
54
|
+
id: string;
|
|
55
|
+
/** The page element */
|
|
56
|
+
element: HTMLElement;
|
|
57
|
+
/** Header element if present */
|
|
58
|
+
header?: HTMLElement;
|
|
59
|
+
/** Content element if present */
|
|
60
|
+
content?: HTMLElement;
|
|
61
|
+
/** Footer element if present */
|
|
62
|
+
footer?: HTMLElement;
|
|
63
|
+
/** Whether this page is currently visible */
|
|
64
|
+
isActive: boolean;
|
|
65
|
+
/** Scroll position to restore */
|
|
66
|
+
scrollPosition?: {
|
|
67
|
+
x: number;
|
|
68
|
+
y: number;
|
|
69
|
+
};
|
|
70
|
+
/** Any custom data attached to this page */
|
|
71
|
+
data?: Record<string, unknown>;
|
|
72
|
+
}
|
|
73
|
+
/** Navigation event details */
|
|
74
|
+
interface NavigationEvent {
|
|
75
|
+
/** Direction of navigation */
|
|
76
|
+
direction: TransitionDirection;
|
|
77
|
+
/** Page being navigated from */
|
|
78
|
+
from?: PageState;
|
|
79
|
+
/** Page being navigated to */
|
|
80
|
+
to: PageState;
|
|
81
|
+
/** Whether animation should be skipped */
|
|
82
|
+
skipAnimation?: boolean;
|
|
83
|
+
}
|
|
84
|
+
/** Lifecycle hooks for page transitions */
|
|
85
|
+
interface TransitionLifecycle {
|
|
86
|
+
/** Called before the page becomes visible (before animation) */
|
|
87
|
+
onWillEnter?: (event: NavigationEvent) => void | Promise<void>;
|
|
88
|
+
/** Called after the page becomes visible (after animation) */
|
|
89
|
+
onDidEnter?: (event: NavigationEvent) => void | Promise<void>;
|
|
90
|
+
/** Called before the page leaves (before animation) */
|
|
91
|
+
onWillLeave?: (event: NavigationEvent) => void | Promise<void>;
|
|
92
|
+
/** Called after the page leaves (after animation) */
|
|
93
|
+
onDidLeave?: (event: NavigationEvent) => void | Promise<void>;
|
|
94
|
+
}
|
|
95
|
+
/** Result of a transition animation */
|
|
96
|
+
interface TransitionResult {
|
|
97
|
+
/** Whether the transition completed successfully */
|
|
98
|
+
success: boolean;
|
|
99
|
+
/** Duration of the transition in ms */
|
|
100
|
+
duration: number;
|
|
101
|
+
/** Any error that occurred */
|
|
102
|
+
error?: Error;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Transition Controller
|
|
107
|
+
* Orchestrates page transitions and manages the navigation stack
|
|
108
|
+
*/
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Transition Controller
|
|
112
|
+
* Central manager for all page transitions
|
|
113
|
+
*/
|
|
114
|
+
declare class TransitionController {
|
|
115
|
+
private config;
|
|
116
|
+
private pageStack;
|
|
117
|
+
private currentAnimations;
|
|
118
|
+
private isAnimating;
|
|
119
|
+
private interactiveBackTransition;
|
|
120
|
+
private lifecycleCallbacks;
|
|
121
|
+
constructor(config?: TransitionGlobalConfig);
|
|
122
|
+
/**
|
|
123
|
+
* Get the resolved platform
|
|
124
|
+
*/
|
|
125
|
+
get platform(): 'ios' | 'android';
|
|
126
|
+
/**
|
|
127
|
+
* Get the current page state
|
|
128
|
+
*/
|
|
129
|
+
get currentPage(): PageState | undefined;
|
|
130
|
+
/**
|
|
131
|
+
* Get the page stack
|
|
132
|
+
*/
|
|
133
|
+
get stack(): readonly PageState[];
|
|
134
|
+
/**
|
|
135
|
+
* Check if an animation is in progress
|
|
136
|
+
*/
|
|
137
|
+
get animating(): boolean;
|
|
138
|
+
/**
|
|
139
|
+
* Update global configuration
|
|
140
|
+
*/
|
|
141
|
+
configure(config: Partial<TransitionGlobalConfig>): void;
|
|
142
|
+
/**
|
|
143
|
+
* Register lifecycle callbacks for a page
|
|
144
|
+
*/
|
|
145
|
+
registerLifecycle(pageId: string, lifecycle: TransitionLifecycle): void;
|
|
146
|
+
/**
|
|
147
|
+
* Unregister lifecycle callbacks for a page
|
|
148
|
+
*/
|
|
149
|
+
unregisterLifecycle(pageId: string): void;
|
|
150
|
+
/**
|
|
151
|
+
* Create a page state from an element
|
|
152
|
+
*/
|
|
153
|
+
createPageState(element: HTMLElement, options?: {
|
|
154
|
+
id?: string;
|
|
155
|
+
data?: Record<string, unknown>;
|
|
156
|
+
}): PageState;
|
|
157
|
+
/**
|
|
158
|
+
* Navigate to a new page (push)
|
|
159
|
+
*/
|
|
160
|
+
push(enteringEl: HTMLElement, config?: TransitionConfig): Promise<TransitionResult>;
|
|
161
|
+
/**
|
|
162
|
+
* Navigate back (pop)
|
|
163
|
+
*/
|
|
164
|
+
pop(config?: TransitionConfig): Promise<TransitionResult>;
|
|
165
|
+
/**
|
|
166
|
+
* Start an interactive iOS-style back transition using the cached previous page.
|
|
167
|
+
*/
|
|
168
|
+
beginInteractiveBack(config?: TransitionConfig): boolean;
|
|
169
|
+
/**
|
|
170
|
+
* Move the current interactive back transition to a progress step from 0 to 1.
|
|
171
|
+
*/
|
|
172
|
+
stepInteractiveBack(step: number): void;
|
|
173
|
+
/**
|
|
174
|
+
* Complete or cancel the current interactive back transition.
|
|
175
|
+
*/
|
|
176
|
+
endInteractiveBack(shouldComplete: boolean, releaseDuration: number, commitStack: boolean): Promise<void>;
|
|
177
|
+
/**
|
|
178
|
+
* Cancel the current interactive back transition immediately.
|
|
179
|
+
*/
|
|
180
|
+
cancelInteractiveBack(): void;
|
|
181
|
+
/**
|
|
182
|
+
* Replace all pages with a new root
|
|
183
|
+
*/
|
|
184
|
+
setRoot(enteringEl: HTMLElement, config?: TransitionConfig): Promise<TransitionResult>;
|
|
185
|
+
/**
|
|
186
|
+
* Main navigation method
|
|
187
|
+
*/
|
|
188
|
+
navigate(enteringEl: HTMLElement, config?: TransitionConfig): Promise<TransitionResult>;
|
|
189
|
+
/**
|
|
190
|
+
* Navigate between two known page states
|
|
191
|
+
*/
|
|
192
|
+
private navigateWithStates;
|
|
193
|
+
/**
|
|
194
|
+
* Update page visibility after animation
|
|
195
|
+
*/
|
|
196
|
+
private updatePageVisibility;
|
|
197
|
+
private getAnimationDuration;
|
|
198
|
+
private playInteractiveAnimationsTo;
|
|
199
|
+
/**
|
|
200
|
+
* Resolve configured easing presets after platform/direction are known.
|
|
201
|
+
*/
|
|
202
|
+
private resolveTransitionEasing;
|
|
203
|
+
/**
|
|
204
|
+
* Remove styles that should only exist while a page is actively transitioning.
|
|
205
|
+
*/
|
|
206
|
+
private clearTransitionOnlyStyles;
|
|
207
|
+
private clearPagePartTransitionStyles;
|
|
208
|
+
/**
|
|
209
|
+
* Prepare entering/leaving elements for a View Transition capture.
|
|
210
|
+
* Entering page must be hidden in the "old" snapshot.
|
|
211
|
+
*/
|
|
212
|
+
private prepareViewTransitionElements;
|
|
213
|
+
/**
|
|
214
|
+
* Assign view transition names to a page's layout parts.
|
|
215
|
+
*/
|
|
216
|
+
private applyViewTransitionNames;
|
|
217
|
+
/**
|
|
218
|
+
* Clear view transition names for one or more page states.
|
|
219
|
+
*/
|
|
220
|
+
private clearViewTransitionNames;
|
|
221
|
+
/**
|
|
222
|
+
* Clear view transition names from all known pages plus transient states.
|
|
223
|
+
*/
|
|
224
|
+
private clearAllKnownViewTransitionNames;
|
|
225
|
+
/**
|
|
226
|
+
* Resolve page parts lazily to avoid timing issues with custom-element setup.
|
|
227
|
+
*/
|
|
228
|
+
private resolvePageParts;
|
|
229
|
+
/**
|
|
230
|
+
* Save scroll position for a page
|
|
231
|
+
*/
|
|
232
|
+
saveScrollPosition(pageId: string): void;
|
|
233
|
+
/**
|
|
234
|
+
* Restore scroll position for a page
|
|
235
|
+
*/
|
|
236
|
+
restoreScrollPosition(pageId: string): void;
|
|
237
|
+
/**
|
|
238
|
+
* Remove a page from the stack (used when cleaning up)
|
|
239
|
+
*/
|
|
240
|
+
removePage(pageId: string): void;
|
|
241
|
+
/**
|
|
242
|
+
* Clear all pages
|
|
243
|
+
*/
|
|
244
|
+
clear(): void;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Svelte bindings for @capgo/capacitor-transitions
|
|
249
|
+
*/
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Initialize the transition system
|
|
253
|
+
*/
|
|
254
|
+
declare function initTransitions(config?: TransitionGlobalConfig): TransitionController;
|
|
255
|
+
/**
|
|
256
|
+
* Get the global transition controller
|
|
257
|
+
*/
|
|
258
|
+
declare function getController(): TransitionController;
|
|
259
|
+
/**
|
|
260
|
+
* Get/set the current transition direction
|
|
261
|
+
*/
|
|
262
|
+
declare function getDirection(): TransitionDirection;
|
|
263
|
+
declare function setDirection(direction: TransitionDirection): void;
|
|
264
|
+
/**
|
|
265
|
+
* Helper for Svelte actions - use on cap-router-outlet
|
|
266
|
+
*/
|
|
267
|
+
interface SvelteActionReturn<T> {
|
|
268
|
+
update?: (newOptions: T) => void;
|
|
269
|
+
destroy?: () => void;
|
|
270
|
+
}
|
|
271
|
+
interface RouterOutletOptions {
|
|
272
|
+
keepInDom?: boolean;
|
|
273
|
+
maxCached?: number;
|
|
274
|
+
platform?: 'ios' | 'android' | 'auto';
|
|
275
|
+
duration?: number;
|
|
276
|
+
swipeGesture?: SwipeGestureOption;
|
|
277
|
+
}
|
|
278
|
+
declare function routerOutlet(node: HTMLElement, options?: RouterOutletOptions): SvelteActionReturn<RouterOutletOptions>;
|
|
279
|
+
interface PageCallbacks {
|
|
280
|
+
onWillEnter?: (event: NavigationEvent) => void;
|
|
281
|
+
onDidEnter?: (event: NavigationEvent) => void;
|
|
282
|
+
onWillLeave?: (event: NavigationEvent) => void;
|
|
283
|
+
onDidLeave?: (event: NavigationEvent) => void;
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Helper for Svelte actions - use on cap-page
|
|
287
|
+
*/
|
|
288
|
+
declare function page(node: HTMLElement, callbacks?: PageCallbacks): SvelteActionReturn<PageCallbacks>;
|
|
289
|
+
/**
|
|
290
|
+
* Helper for navigation with transitions
|
|
291
|
+
*/
|
|
292
|
+
declare function navigateWithTransition(navigate: (to: string) => void, to: string, direction?: TransitionDirection): void;
|
|
293
|
+
/**
|
|
294
|
+
* Create a transition-aware navigate function
|
|
295
|
+
*/
|
|
296
|
+
declare function createTransitionNavigate(navigate: (to: string) => void): (to: string, direction?: TransitionDirection) => void;
|
|
297
|
+
|
|
298
|
+
export { type NavigationEvent, type SwipeGestureOption, TransitionController, type TransitionDirection, type TransitionGlobalConfig, createTransitionNavigate, getController, getDirection, initTransitions, navigateWithTransition, page, routerOutlet, setDirection };
|