@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.
@@ -0,0 +1,734 @@
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
+ /** Runtime platform reported by Capacitor when available */
10
+ type NativePlatform = 'ios' | 'android' | 'web' | 'unknown';
11
+ /** Whether the edge swipe-back gesture is enabled, disabled, or native-detected */
12
+ type SwipeGestureOption = boolean | 'auto';
13
+ /** Which parts of the page to animate */
14
+ type TransitionTarget = 'header' | 'content' | 'footer' | 'all';
15
+ /** Animation easing presets */
16
+ type TransitionEasing = 'linear' | 'ease' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'ios' | 'android' | string;
17
+ /** Configuration for a single transition animation */
18
+ interface TransitionConfig {
19
+ /** Duration in milliseconds (default: 540 for iOS, 280/200 for Android forward/back) */
20
+ duration?: number;
21
+ /** Easing function (default: 'ios' or 'android' based on platform) */
22
+ easing?: TransitionEasing;
23
+ /** Direction of transition */
24
+ direction?: TransitionDirection;
25
+ /** Which elements to animate (default: 'all') */
26
+ targets?: TransitionTarget[];
27
+ /** Custom animation keyframes for entering element */
28
+ enterKeyframes?: Keyframe[];
29
+ /** Custom animation keyframes for leaving element */
30
+ leaveKeyframes?: Keyframe[];
31
+ /** Callback before animation starts */
32
+ onStart?: () => void;
33
+ /** Callback after animation completes */
34
+ onComplete?: () => void;
35
+ /** Whether to use View Transitions API when available (default: false) */
36
+ useViewTransitions?: boolean;
37
+ }
38
+ /** Capacitor native runtime detection result */
39
+ interface NativePlatformInfo {
40
+ /** Platform name from Capacitor.getPlatform() when available */
41
+ platform: NativePlatform;
42
+ /** Whether Capacitor reports a native installed app runtime */
43
+ isNative: boolean;
44
+ }
45
+ /** Resolved platform type (excludes 'auto') */
46
+ type ResolvedPlatform = 'ios' | 'android';
47
+ /** Global configuration for the transition system */
48
+ interface TransitionGlobalConfig {
49
+ /** Default platform style (default: 'auto') */
50
+ platform?: TransitionPlatform;
51
+ /** Default duration in ms */
52
+ duration?: number;
53
+ /** Default easing */
54
+ easing?: TransitionEasing;
55
+ /** Whether to use View Transitions API (default: false) */
56
+ useViewTransitions?: boolean;
57
+ /** Custom platform detection function */
58
+ detectPlatform?: () => ResolvedPlatform;
59
+ }
60
+ /** State of a page in the navigation stack */
61
+ interface PageState {
62
+ /** Unique identifier for the page */
63
+ id: string;
64
+ /** The page element */
65
+ element: HTMLElement;
66
+ /** Header element if present */
67
+ header?: HTMLElement;
68
+ /** Content element if present */
69
+ content?: HTMLElement;
70
+ /** Footer element if present */
71
+ footer?: HTMLElement;
72
+ /** Whether this page is currently visible */
73
+ isActive: boolean;
74
+ /** Scroll position to restore */
75
+ scrollPosition?: {
76
+ x: number;
77
+ y: number;
78
+ };
79
+ /** Any custom data attached to this page */
80
+ data?: Record<string, unknown>;
81
+ }
82
+ /** Navigation event details */
83
+ interface NavigationEvent {
84
+ /** Direction of navigation */
85
+ direction: TransitionDirection;
86
+ /** Page being navigated from */
87
+ from?: PageState;
88
+ /** Page being navigated to */
89
+ to: PageState;
90
+ /** Whether animation should be skipped */
91
+ skipAnimation?: boolean;
92
+ }
93
+ /** Lifecycle hooks for page transitions */
94
+ interface TransitionLifecycle {
95
+ /** Called before the page becomes visible (before animation) */
96
+ onWillEnter?: (event: NavigationEvent) => void | Promise<void>;
97
+ /** Called after the page becomes visible (after animation) */
98
+ onDidEnter?: (event: NavigationEvent) => void | Promise<void>;
99
+ /** Called before the page leaves (before animation) */
100
+ onWillLeave?: (event: NavigationEvent) => void | Promise<void>;
101
+ /** Called after the page leaves (after animation) */
102
+ onDidLeave?: (event: NavigationEvent) => void | Promise<void>;
103
+ }
104
+ /** Animation builder function signature (similar to Ionic) */
105
+ type AnimationBuilder = (baseElement: HTMLElement, options: TransitionAnimationOptions) => Animation | Animation[];
106
+ /** Options passed to animation builders */
107
+ interface TransitionAnimationOptions {
108
+ /** Element entering the view */
109
+ enteringEl: HTMLElement;
110
+ /** Element leaving the view */
111
+ leavingEl?: HTMLElement;
112
+ /** Direction of the transition */
113
+ direction: TransitionDirection;
114
+ /** Duration in ms */
115
+ duration: number;
116
+ /** Easing function */
117
+ easing: string;
118
+ /** Whether this is a back navigation */
119
+ isBack: boolean;
120
+ }
121
+ /** Result of a transition animation */
122
+ interface TransitionResult {
123
+ /** Whether the transition completed successfully */
124
+ success: boolean;
125
+ /** Duration of the transition in ms */
126
+ duration: number;
127
+ /** Any error that occurred */
128
+ error?: Error;
129
+ }
130
+ /** Router outlet options */
131
+ interface RouterOutletOptions {
132
+ /** Keep pages in DOM after navigating away (default: true) */
133
+ keepInDom?: boolean;
134
+ /** Maximum number of pages to keep in DOM (default: 10) */
135
+ maxCachedPages?: number;
136
+ /** Custom animation builder */
137
+ animation?: AnimationBuilder;
138
+ /** Transition configuration */
139
+ transition?: TransitionConfig;
140
+ /** Edge swipe-back gesture support (default: 'auto', native iOS only) */
141
+ swipeGesture?: SwipeGestureOption;
142
+ }
143
+ /** Page component options */
144
+ interface PageOptions {
145
+ /** Unique key for this page (used for caching) */
146
+ key?: string;
147
+ /** Whether to cache scroll position (default: true) */
148
+ cacheScroll?: boolean;
149
+ /** Lifecycle hooks */
150
+ lifecycle?: TransitionLifecycle;
151
+ }
152
+
153
+ /**
154
+ * Transition Controller
155
+ * Orchestrates page transitions and manages the navigation stack
156
+ */
157
+
158
+ /**
159
+ * Transition Controller
160
+ * Central manager for all page transitions
161
+ */
162
+ declare class TransitionController {
163
+ private config;
164
+ private pageStack;
165
+ private currentAnimations;
166
+ private isAnimating;
167
+ private interactiveBackTransition;
168
+ private lifecycleCallbacks;
169
+ constructor(config?: TransitionGlobalConfig);
170
+ /**
171
+ * Get the resolved platform
172
+ */
173
+ get platform(): 'ios' | 'android';
174
+ /**
175
+ * Get the current page state
176
+ */
177
+ get currentPage(): PageState | undefined;
178
+ /**
179
+ * Get the page stack
180
+ */
181
+ get stack(): readonly PageState[];
182
+ /**
183
+ * Check if an animation is in progress
184
+ */
185
+ get animating(): boolean;
186
+ /**
187
+ * Update global configuration
188
+ */
189
+ configure(config: Partial<TransitionGlobalConfig>): void;
190
+ /**
191
+ * Register lifecycle callbacks for a page
192
+ */
193
+ registerLifecycle(pageId: string, lifecycle: TransitionLifecycle): void;
194
+ /**
195
+ * Unregister lifecycle callbacks for a page
196
+ */
197
+ unregisterLifecycle(pageId: string): void;
198
+ /**
199
+ * Create a page state from an element
200
+ */
201
+ createPageState(element: HTMLElement, options?: {
202
+ id?: string;
203
+ data?: Record<string, unknown>;
204
+ }): PageState;
205
+ /**
206
+ * Navigate to a new page (push)
207
+ */
208
+ push(enteringEl: HTMLElement, config?: TransitionConfig): Promise<TransitionResult>;
209
+ /**
210
+ * Navigate back (pop)
211
+ */
212
+ pop(config?: TransitionConfig): Promise<TransitionResult>;
213
+ /**
214
+ * Start an interactive iOS-style back transition using the cached previous page.
215
+ */
216
+ beginInteractiveBack(config?: TransitionConfig): boolean;
217
+ /**
218
+ * Move the current interactive back transition to a progress step from 0 to 1.
219
+ */
220
+ stepInteractiveBack(step: number): void;
221
+ /**
222
+ * Complete or cancel the current interactive back transition.
223
+ */
224
+ endInteractiveBack(shouldComplete: boolean, releaseDuration: number, commitStack: boolean): Promise<void>;
225
+ /**
226
+ * Cancel the current interactive back transition immediately.
227
+ */
228
+ cancelInteractiveBack(): void;
229
+ /**
230
+ * Replace all pages with a new root
231
+ */
232
+ setRoot(enteringEl: HTMLElement, config?: TransitionConfig): Promise<TransitionResult>;
233
+ /**
234
+ * Main navigation method
235
+ */
236
+ navigate(enteringEl: HTMLElement, config?: TransitionConfig): Promise<TransitionResult>;
237
+ /**
238
+ * Navigate between two known page states
239
+ */
240
+ private navigateWithStates;
241
+ /**
242
+ * Update page visibility after animation
243
+ */
244
+ private updatePageVisibility;
245
+ private getAnimationDuration;
246
+ private playInteractiveAnimationsTo;
247
+ /**
248
+ * Resolve configured easing presets after platform/direction are known.
249
+ */
250
+ private resolveTransitionEasing;
251
+ /**
252
+ * Remove styles that should only exist while a page is actively transitioning.
253
+ */
254
+ private clearTransitionOnlyStyles;
255
+ private clearPagePartTransitionStyles;
256
+ /**
257
+ * Prepare entering/leaving elements for a View Transition capture.
258
+ * Entering page must be hidden in the "old" snapshot.
259
+ */
260
+ private prepareViewTransitionElements;
261
+ /**
262
+ * Assign view transition names to a page's layout parts.
263
+ */
264
+ private applyViewTransitionNames;
265
+ /**
266
+ * Clear view transition names for one or more page states.
267
+ */
268
+ private clearViewTransitionNames;
269
+ /**
270
+ * Clear view transition names from all known pages plus transient states.
271
+ */
272
+ private clearAllKnownViewTransitionNames;
273
+ /**
274
+ * Resolve page parts lazily to avoid timing issues with custom-element setup.
275
+ */
276
+ private resolvePageParts;
277
+ /**
278
+ * Save scroll position for a page
279
+ */
280
+ saveScrollPosition(pageId: string): void;
281
+ /**
282
+ * Restore scroll position for a page
283
+ */
284
+ restoreScrollPosition(pageId: string): void;
285
+ /**
286
+ * Remove a page from the stack (used when cleaning up)
287
+ */
288
+ removePage(pageId: string): void;
289
+ /**
290
+ * Clear all pages
291
+ */
292
+ clear(): void;
293
+ }
294
+ /**
295
+ * Get or create the default transition controller
296
+ */
297
+ declare function getTransitionController(config?: TransitionGlobalConfig): TransitionController;
298
+ /**
299
+ * Create a new transition controller
300
+ */
301
+ declare function createTransitionController(config?: TransitionGlobalConfig): TransitionController;
302
+
303
+ /**
304
+ * Cap Router Outlet
305
+ * A web component that manages page transitions
306
+ * Works with any framework's router
307
+ */
308
+
309
+ /**
310
+ * Custom element for managing page transitions
311
+ * Usage: <cap-router-outlet></cap-router-outlet>
312
+ */
313
+ declare class CapRouterOutlet extends HTMLElement {
314
+ private controller;
315
+ private options;
316
+ private observer;
317
+ private pendingPage;
318
+ private ignoredNodes;
319
+ private swipeGesturePointer;
320
+ private swipeGestureListenersActive;
321
+ private skipNextHistoryBackTransition;
322
+ private swipeBackDepth;
323
+ private lastNavigationHref;
324
+ private readonly swipeGestureEdgeWidth;
325
+ private readonly swipeGestureThreshold;
326
+ private readonly swipeGestureMinimumVelocity;
327
+ static get observedAttributes(): string[];
328
+ constructor();
329
+ connectedCallback(): void;
330
+ disconnectedCallback(): void;
331
+ attributeChangedCallback(name: string, _oldValue: string, newValue: string): void;
332
+ /**
333
+ * Handle DOM mutations (child additions/removals)
334
+ */
335
+ private handleMutations;
336
+ /**
337
+ * Initialize the first page without animation
338
+ */
339
+ private initializeFirstPage;
340
+ /**
341
+ * Handle a new page being added
342
+ */
343
+ private handleNewPage;
344
+ /**
345
+ * Clean up pages that are no longer needed
346
+ */
347
+ private cleanupOldPages;
348
+ /**
349
+ * Enforce the cache limit
350
+ */
351
+ private enforceCacheLimit;
352
+ /**
353
+ * Programmatic navigation - push a new page
354
+ */
355
+ push(page: HTMLElement, config?: TransitionConfig): Promise<void>;
356
+ /**
357
+ * Programmatic navigation - pop current page
358
+ */
359
+ pop(config?: TransitionConfig): Promise<void>;
360
+ /**
361
+ * Programmatic navigation - set root page
362
+ */
363
+ setRoot(page: HTMLElement, config?: TransitionConfig): Promise<void>;
364
+ /**
365
+ * Get the current page stack length
366
+ */
367
+ get stackLength(): number;
368
+ /**
369
+ * Check if we can go back
370
+ */
371
+ get canGoBack(): boolean;
372
+ /**
373
+ * Get whether edge swipe-back gesture is enabled.
374
+ */
375
+ get swipeGesture(): SwipeGestureOption;
376
+ /**
377
+ * Enable, disable, or auto-detect edge swipe-back gesture.
378
+ */
379
+ set swipeGesture(value: SwipeGestureOption);
380
+ /**
381
+ * Enable, disable, or auto-detect edge swipe-back gesture.
382
+ */
383
+ setSwipeGesture(value: SwipeGestureOption): void;
384
+ /**
385
+ * Get the transition controller for advanced usage
386
+ */
387
+ getController(): TransitionController;
388
+ /**
389
+ * Apply layout styles required for transition animations.
390
+ */
391
+ private stylePageForTransition;
392
+ private parseSwipeGestureAttribute;
393
+ private serializeSwipeGesture;
394
+ private updateSwipeGestureListeners;
395
+ private removeSwipeGestureListeners;
396
+ private isSwipeGestureEnabled;
397
+ private getCurrentNavigationHref;
398
+ private recordCompletedNavigation;
399
+ private canStartSwipeGesture;
400
+ private isRTL;
401
+ private getSwipeGestureDeltaX;
402
+ private isInteractiveSwipeTarget;
403
+ private hasScrollableInlineAncestor;
404
+ private handleSwipeGesturePointerDown;
405
+ private handleSwipeGesturePointerMove;
406
+ private handleSwipeGesturePointerEnd;
407
+ private handleSwipeGesturePointerCancel;
408
+ private cancelSwipeGesturePointer;
409
+ private releaseSwipeGesturePointer;
410
+ private cancelSwipeGesture;
411
+ private finishSwipeGestureBack;
412
+ }
413
+
414
+ /**
415
+ * Cap Page
416
+ * A container for page content with header, content, and footer slots
417
+ * Integrates with cap-router-outlet for transitions
418
+ */
419
+
420
+ /**
421
+ * Custom element for a page container
422
+ * Usage:
423
+ * <cap-page>
424
+ * <cap-header slot="header">...</cap-header>
425
+ * <cap-content slot="content">...</cap-content>
426
+ * <cap-footer slot="footer">...</cap-footer>
427
+ * </cap-page>
428
+ */
429
+ declare class CapPage extends HTMLElement {
430
+ private _lifecycle;
431
+ private _isActive;
432
+ static get observedAttributes(): string[];
433
+ constructor();
434
+ connectedCallback(): void;
435
+ disconnectedCallback(): void;
436
+ /**
437
+ * Mark child elements for transition controller
438
+ */
439
+ private markTransitionElements;
440
+ /**
441
+ * Set lifecycle callbacks
442
+ */
443
+ set lifecycle(callbacks: TransitionLifecycle);
444
+ get lifecycle(): TransitionLifecycle;
445
+ /**
446
+ * Check if page is active
447
+ */
448
+ get isActive(): boolean;
449
+ /**
450
+ * Called when page will enter view
451
+ */
452
+ willEnter(event: NavigationEvent): Promise<void>;
453
+ /**
454
+ * Called when page has entered view
455
+ */
456
+ didEnter(event: NavigationEvent): Promise<void>;
457
+ /**
458
+ * Called when page will leave view
459
+ */
460
+ willLeave(event: NavigationEvent): Promise<void>;
461
+ /**
462
+ * Called when page has left view
463
+ */
464
+ didLeave(event: NavigationEvent): Promise<void>;
465
+ /**
466
+ * Get the header element
467
+ */
468
+ get headerElement(): HTMLElement | null;
469
+ /**
470
+ * Get the content element
471
+ */
472
+ get contentElement(): HTMLElement | null;
473
+ /**
474
+ * Get the footer element
475
+ */
476
+ get footerElement(): HTMLElement | null;
477
+ /**
478
+ * Save scroll position
479
+ */
480
+ saveScrollPosition(): {
481
+ x: number;
482
+ y: number;
483
+ } | null;
484
+ /**
485
+ * Restore scroll position
486
+ */
487
+ restoreScrollPosition(position: {
488
+ x: number;
489
+ y: number;
490
+ }): void;
491
+ }
492
+
493
+ /**
494
+ * Cap Header
495
+ * A header container that participates in page transitions
496
+ * No styling opinions - just transition awareness
497
+ */
498
+ /**
499
+ * Custom element for header content
500
+ * Usage: <cap-header>Your header content</cap-header>
501
+ */
502
+ declare class CapHeader extends HTMLElement {
503
+ static get observedAttributes(): string[];
504
+ constructor();
505
+ connectedCallback(): void;
506
+ attributeChangedCallback(name: string, _oldValue: string, newValue: string): void;
507
+ /**
508
+ * Get the current height of the header
509
+ */
510
+ get height(): number;
511
+ }
512
+
513
+ /**
514
+ * Cap Content
515
+ * Main scrollable content area that participates in page transitions
516
+ * No styling opinions - just transition awareness and scroll management
517
+ */
518
+ /**
519
+ * Custom element for main content
520
+ * Usage: <cap-content>Your content here</cap-content>
521
+ */
522
+ declare class CapContent extends HTMLElement {
523
+ private _scrollPosition;
524
+ static get observedAttributes(): string[];
525
+ constructor();
526
+ connectedCallback(): void;
527
+ disconnectedCallback(): void;
528
+ attributeChangedCallback(name: string, _oldValue: string, newValue: string): void;
529
+ /**
530
+ * Handle scroll events
531
+ */
532
+ private handleScroll;
533
+ /**
534
+ * Get current scroll position
535
+ */
536
+ get scrollPosition(): {
537
+ x: number;
538
+ y: number;
539
+ };
540
+ /**
541
+ * Save current scroll position
542
+ */
543
+ saveScrollPosition(): {
544
+ x: number;
545
+ y: number;
546
+ };
547
+ /**
548
+ * Restore scroll position
549
+ */
550
+ restoreScrollPosition(position?: {
551
+ x: number;
552
+ y: number;
553
+ }): void;
554
+ /**
555
+ * Scroll to top
556
+ */
557
+ scrollToTop(smooth?: boolean): void;
558
+ /**
559
+ * Scroll to bottom
560
+ */
561
+ scrollToBottom(smooth?: boolean): void;
562
+ /**
563
+ * Scroll to element
564
+ */
565
+ scrollToElement(element: HTMLElement, smooth?: boolean): void;
566
+ }
567
+
568
+ /**
569
+ * Cap Footer
570
+ * A footer container that participates in page transitions
571
+ * No styling opinions - just transition awareness
572
+ */
573
+ /**
574
+ * Custom element for footer content
575
+ * Usage: <cap-footer>Your footer content</cap-footer>
576
+ */
577
+ declare class CapFooter extends HTMLElement {
578
+ static get observedAttributes(): string[];
579
+ constructor();
580
+ connectedCallback(): void;
581
+ attributeChangedCallback(name: string, _oldValue: string, newValue: string): void;
582
+ /**
583
+ * Get the current height of the footer
584
+ */
585
+ get height(): number;
586
+ }
587
+
588
+ /**
589
+ * Core animation system using Web Animations API
590
+ * Provides iOS and Android style page transitions
591
+ */
592
+
593
+ /** iOS easing curve - matches UIKit spring animation feel */
594
+ declare const IOS_EASING = "cubic-bezier(0.32, 0.72, 0, 1)";
595
+ /** Android Material Design forward easing */
596
+ declare const ANDROID_EASING = "cubic-bezier(0.36, 0.66, 0.04, 1)";
597
+ /** Default iOS transition duration */
598
+ declare const IOS_DURATION = 540;
599
+ /** Default Android forward transition duration */
600
+ declare const ANDROID_DURATION = 280;
601
+ /**
602
+ * Resolve easing string to CSS value
603
+ */
604
+ declare function resolveEasing(easing: TransitionEasing): string;
605
+ /**
606
+ * Detect platform from user agent
607
+ */
608
+ declare function detectPlatform(): ResolvedPlatform;
609
+ /**
610
+ * Get default duration for platform
611
+ */
612
+ declare function getDefaultDuration(platform: TransitionPlatform, direction?: 'forward' | 'back' | 'root' | 'none'): number;
613
+ /**
614
+ * Get default easing for platform
615
+ */
616
+ declare function getDefaultEasing(platform: TransitionPlatform, direction?: 'forward' | 'back' | 'root' | 'none'): string;
617
+ /**
618
+ * iOS-style horizontal slide transition
619
+ * Forward: new page slides in from right
620
+ * Back: old page slides out to right
621
+ */
622
+ declare function createIOSTransition(options: TransitionAnimationOptions): Animation[];
623
+ /**
624
+ * Android-style vertical slide transition
625
+ * Forward: new page slides up from bottom
626
+ * Back: old page slides down to bottom
627
+ */
628
+ declare function createAndroidTransition(options: TransitionAnimationOptions): Animation[];
629
+ /**
630
+ * No animation - instant transition
631
+ */
632
+ declare function createNoneTransition(options: TransitionAnimationOptions): Animation[];
633
+ /**
634
+ * Create platform-appropriate transition
635
+ */
636
+ declare function createTransition(options: TransitionAnimationOptions, platform?: TransitionPlatform): Animation[];
637
+ /**
638
+ * Wait for all animations to complete
639
+ */
640
+ declare function waitForAnimations(animations: Animation[]): Promise<void>;
641
+ /**
642
+ * Cancel all animations
643
+ */
644
+ declare function cancelAnimations(animations: Animation[]): void;
645
+ /**
646
+ * Create header-specific animation
647
+ * Headers can have different animations (e.g., title changes, back button appears)
648
+ */
649
+ declare function createHeaderTransition(options: TransitionAnimationOptions & {
650
+ enteringHeader?: HTMLElement;
651
+ leavingHeader?: HTMLElement;
652
+ }): Animation[];
653
+ /**
654
+ * Create footer-specific animation
655
+ * Footers typically stay in place or fade
656
+ */
657
+ declare function createFooterTransition(options: TransitionAnimationOptions & {
658
+ enteringFooter?: HTMLElement;
659
+ leavingFooter?: HTMLElement;
660
+ }): Animation[];
661
+
662
+ /**
663
+ * View Transitions API support
664
+ * Progressive enhancement for browsers that support it
665
+ */
666
+
667
+ /** Check if View Transitions API is supported */
668
+ declare function supportsViewTransitions(): boolean;
669
+ /** View transition options */
670
+ interface ViewTransitionOptions {
671
+ /** Callback to update the DOM */
672
+ update: () => void | Promise<void>;
673
+ /** Direction for animation classes */
674
+ direction?: TransitionDirection;
675
+ /** Custom view transition names to apply */
676
+ names?: {
677
+ header?: string;
678
+ content?: string;
679
+ footer?: string;
680
+ };
681
+ /** Skip animation */
682
+ skipAnimation?: boolean;
683
+ }
684
+ /**
685
+ * Run a transition with View Transitions API if available
686
+ * Falls back to immediate update if not supported
687
+ */
688
+ declare function runViewTransition(options: ViewTransitionOptions): Promise<void>;
689
+ /**
690
+ * Apply view transition name to an element
691
+ */
692
+ declare function setViewTransitionName(element: HTMLElement, name: string): void;
693
+ /**
694
+ * Remove view transition name from an element
695
+ */
696
+ declare function clearViewTransitionName(element: HTMLElement): void;
697
+ /**
698
+ * CSS for View Transitions API integration
699
+ * This can be injected into the page to enable smooth transitions
700
+ */
701
+ declare const VIEW_TRANSITIONS_CSS = "\n/* View Transitions API base styles */\n::view-transition-old(root),\n::view-transition-new(root) {\n animation-duration: 0.4s;\n animation-timing-function: cubic-bezier(0.32, 0.72, 0, 1);\n}\n\n/* iOS-style forward navigation */\n[data-transition-direction=\"forward\"]::view-transition-old(root) {\n animation-name: cap-slide-out-left;\n}\n\n[data-transition-direction=\"forward\"]::view-transition-new(root) {\n animation-name: cap-slide-in-right;\n}\n\n/* iOS-style back navigation */\n[data-transition-direction=\"back\"]::view-transition-old(root) {\n animation-name: cap-slide-out-right;\n}\n\n[data-transition-direction=\"back\"]::view-transition-new(root) {\n animation-name: cap-slide-in-left;\n}\n\n/* Root/replace navigation - fade */\n[data-transition-direction=\"root\"]::view-transition-old(root) {\n animation-name: cap-fade-out;\n}\n\n[data-transition-direction=\"root\"]::view-transition-new(root) {\n animation-name: cap-fade-in;\n}\n\n/* Header transitions */\n::view-transition-old(cap-header),\n::view-transition-new(cap-header) {\n animation-duration: 0.3s;\n}\n\n[data-transition-direction=\"forward\"]::view-transition-old(cap-header) {\n animation-name: cap-header-out-left;\n}\n\n[data-transition-direction=\"forward\"]::view-transition-new(cap-header) {\n animation-name: cap-header-in-right;\n}\n\n[data-transition-direction=\"back\"]::view-transition-old(cap-header) {\n animation-name: cap-header-out-right;\n}\n\n[data-transition-direction=\"back\"]::view-transition-new(cap-header) {\n animation-name: cap-header-in-left;\n}\n\n/* Content transitions */\n::view-transition-old(cap-content),\n::view-transition-new(cap-content) {\n animation-duration: 0.4s;\n animation-timing-function: cubic-bezier(0.32, 0.72, 0, 1);\n}\n\n[data-transition-direction=\"forward\"]::view-transition-old(cap-content) {\n animation-name: cap-slide-out-left;\n}\n\n[data-transition-direction=\"forward\"]::view-transition-new(cap-content) {\n animation-name: cap-slide-in-right;\n}\n\n[data-transition-direction=\"back\"]::view-transition-old(cap-content) {\n animation-name: cap-slide-out-right;\n}\n\n[data-transition-direction=\"back\"]::view-transition-new(cap-content) {\n animation-name: cap-slide-in-left;\n}\n\n/* Animation keyframes */\n@keyframes cap-slide-in-right {\n from {\n transform: translateX(100%);\n opacity: 1;\n }\n to {\n transform: translateX(0);\n opacity: 1;\n }\n}\n\n@keyframes cap-slide-out-left {\n from {\n transform: translateX(0);\n opacity: 1;\n }\n to {\n transform: translateX(-30%);\n opacity: 0.8;\n }\n}\n\n@keyframes cap-slide-in-left {\n from {\n transform: translateX(-30%);\n opacity: 0.8;\n }\n to {\n transform: translateX(0);\n opacity: 1;\n }\n}\n\n@keyframes cap-slide-out-right {\n from {\n transform: translateX(0);\n opacity: 1;\n }\n to {\n transform: translateX(100%);\n opacity: 1;\n }\n}\n\n@keyframes cap-fade-in {\n from { opacity: 0; }\n to { opacity: 1; }\n}\n\n@keyframes cap-fade-out {\n from { opacity: 1; }\n to { opacity: 0; }\n}\n\n@keyframes cap-header-in-right {\n from {\n transform: translateX(20px);\n opacity: 0;\n }\n to {\n transform: translateX(0);\n opacity: 1;\n }\n}\n\n@keyframes cap-header-out-left {\n from {\n transform: translateX(0);\n opacity: 1;\n }\n to {\n transform: translateX(-20px);\n opacity: 0;\n }\n}\n\n@keyframes cap-header-in-left {\n from {\n transform: translateX(-20px);\n opacity: 0;\n }\n to {\n transform: translateX(0);\n opacity: 1;\n }\n}\n\n@keyframes cap-header-out-right {\n from {\n transform: translateX(0);\n opacity: 1;\n }\n to {\n transform: translateX(20px);\n opacity: 0;\n }\n}\n\n/* Reduced motion support */\n@media (prefers-reduced-motion: reduce) {\n ::view-transition-old(root),\n ::view-transition-new(root),\n ::view-transition-old(cap-header),\n ::view-transition-new(cap-header),\n ::view-transition-old(cap-content),\n ::view-transition-new(cap-content) {\n animation-duration: 0.01ms !important;\n }\n}\n";
702
+ /**
703
+ * Inject View Transitions CSS into the page
704
+ */
705
+ declare function injectViewTransitionsCSS(): void;
706
+
707
+ declare function detectNativePlatform(): NativePlatformInfo;
708
+ declare function isNativeSwipeGesturePlatform(): boolean;
709
+
710
+ /**
711
+ * @capgo/capacitor-transitions
712
+ * Framework-agnostic page transitions for Capacitor apps
713
+ *
714
+ * Features:
715
+ * - iOS and Android style transitions
716
+ * - Works with any framework (React, Vue, Angular, Svelte, Solid, etc.)
717
+ * - Uses Web Animations API for smooth, GPU-accelerated transitions
718
+ * - Supports View Transitions API as optional progressive enhancement
719
+ * - No styling opinions - just transition logic
720
+ * - Coordinates header, content, and footer animations
721
+ */
722
+
723
+ declare function initCapTransitions(): void;
724
+ declare global {
725
+ interface HTMLElementTagNameMap {
726
+ 'cap-router-outlet': CapRouterOutlet;
727
+ 'cap-page': CapPage;
728
+ 'cap-header': CapHeader;
729
+ 'cap-content': CapContent;
730
+ 'cap-footer': CapFooter;
731
+ }
732
+ }
733
+
734
+ export { ANDROID_DURATION, ANDROID_EASING, type AnimationBuilder, CapContent, CapFooter, CapHeader, CapPage, CapRouterOutlet, IOS_DURATION, IOS_EASING, type NativePlatform, type NativePlatformInfo, type NavigationEvent, type PageOptions, type PageState, type ResolvedPlatform, type RouterOutletOptions, type SwipeGestureOption, type TransitionAnimationOptions, type TransitionConfig, TransitionController, type TransitionDirection, type TransitionEasing, type TransitionGlobalConfig, type TransitionLifecycle, type TransitionPlatform, type TransitionResult, type TransitionTarget, VIEW_TRANSITIONS_CSS, cancelAnimations, clearViewTransitionName, createAndroidTransition, createFooterTransition, createHeaderTransition, createIOSTransition, createNoneTransition, createTransition, createTransitionController, detectNativePlatform, detectPlatform, getDefaultDuration, getDefaultEasing, getTransitionController, initCapTransitions, injectViewTransitionsCSS, isNativeSwipeGesturePlatform, resolveEasing, runViewTransition, setViewTransitionName, supportsViewTransitions, waitForAnimations };