@capgo/capacitor-transitions 8.0.3 → 8.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/README.md +50 -3
- package/dist/{chunk-LABKGL2K.mjs → chunk-B6BVMPJ3.mjs} +58 -7
- package/dist/chunk-B6BVMPJ3.mjs.map +1 -0
- package/dist/{components-M5B63NYZ.mjs → components-HRZG74NZ.mjs} +2 -2
- package/dist/index.d.mts +10 -1
- package/dist/index.d.ts +10 -1
- package/dist/index.js +63 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/dist/react/index.d.mts +13 -1
- package/dist/react/index.d.ts +13 -1
- package/dist/react/index.js +68 -7
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +67 -7
- package/dist/react/index.mjs.map +1 -1
- package/dist/solid/index.d.mts +10 -1
- package/dist/solid/index.d.ts +10 -1
- package/dist/solid/index.js +68 -7
- package/dist/solid/index.js.map +1 -1
- package/dist/solid/index.mjs +67 -7
- package/dist/solid/index.mjs.map +1 -1
- package/dist/svelte/index.d.mts +10 -1
- package/dist/svelte/index.d.ts +10 -1
- package/dist/svelte/index.js +70 -9
- package/dist/svelte/index.js.map +1 -1
- package/dist/svelte/index.mjs +68 -8
- package/dist/svelte/index.mjs.map +1 -1
- package/dist/vue/index.d.mts +10 -1
- package/dist/vue/index.d.ts +10 -1
- package/dist/vue/index.js +68 -7
- package/dist/vue/index.js.map +1 -1
- package/dist/vue/index.mjs +67 -7
- package/dist/vue/index.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-LABKGL2K.mjs.map +0 -1
- /package/dist/{components-M5B63NYZ.mjs.map → components-HRZG74NZ.mjs.map} +0 -0
package/dist/index.d.mts
CHANGED
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
*/
|
|
5
5
|
/** Direction of the navigation transition */
|
|
6
6
|
type TransitionDirection = 'forward' | 'back' | 'root' | 'none';
|
|
7
|
+
/** Navigation stack action to record independently from the animation direction */
|
|
8
|
+
type NavigationAction = 'forward' | 'back' | 'root' | 'none';
|
|
7
9
|
/** Platform-specific animation styles */
|
|
8
10
|
type TransitionPlatform = 'ios' | 'android' | 'auto';
|
|
9
11
|
/** Runtime platform reported by Capacitor when available */
|
|
@@ -22,6 +24,8 @@ interface TransitionConfig {
|
|
|
22
24
|
easing?: TransitionEasing;
|
|
23
25
|
/** Direction of transition */
|
|
24
26
|
direction?: TransitionDirection;
|
|
27
|
+
/** Navigation stack action (default: follows direction, except 'none' keeps push behavior for compatibility) */
|
|
28
|
+
navigationAction?: NavigationAction;
|
|
25
29
|
/** Which elements to animate (default: 'all') */
|
|
26
30
|
targets?: TransitionTarget[];
|
|
27
31
|
/** Custom animation keyframes for entering element */
|
|
@@ -234,6 +238,7 @@ declare class TransitionController {
|
|
|
234
238
|
* Main navigation method
|
|
235
239
|
*/
|
|
236
240
|
navigate(enteringEl: HTMLElement, config?: TransitionConfig): Promise<TransitionResult>;
|
|
241
|
+
private resolveNavigationAction;
|
|
237
242
|
/**
|
|
238
243
|
* Navigate between two known page states
|
|
239
244
|
*/
|
|
@@ -387,6 +392,10 @@ declare class CapRouterOutlet extends HTMLElement {
|
|
|
387
392
|
* Enable, disable, or auto-detect edge swipe-back gesture.
|
|
388
393
|
*/
|
|
389
394
|
setSwipeGesture(value: SwipeGestureOption): void;
|
|
395
|
+
/**
|
|
396
|
+
* Set the navigation stack action and animation direction for the next router-driven navigation.
|
|
397
|
+
*/
|
|
398
|
+
setNavigation(action: NavigationAction, direction?: TransitionDirection): void;
|
|
390
399
|
/**
|
|
391
400
|
* Get the transition controller for advanced usage
|
|
392
401
|
*/
|
|
@@ -747,4 +756,4 @@ declare global {
|
|
|
747
756
|
}
|
|
748
757
|
}
|
|
749
758
|
|
|
750
|
-
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 };
|
|
759
|
+
export { ANDROID_DURATION, ANDROID_EASING, type AnimationBuilder, CapContent, CapFooter, CapHeader, CapPage, CapRouterOutlet, IOS_DURATION, IOS_EASING, type NativePlatform, type NativePlatformInfo, type NavigationAction, 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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
*/
|
|
5
5
|
/** Direction of the navigation transition */
|
|
6
6
|
type TransitionDirection = 'forward' | 'back' | 'root' | 'none';
|
|
7
|
+
/** Navigation stack action to record independently from the animation direction */
|
|
8
|
+
type NavigationAction = 'forward' | 'back' | 'root' | 'none';
|
|
7
9
|
/** Platform-specific animation styles */
|
|
8
10
|
type TransitionPlatform = 'ios' | 'android' | 'auto';
|
|
9
11
|
/** Runtime platform reported by Capacitor when available */
|
|
@@ -22,6 +24,8 @@ interface TransitionConfig {
|
|
|
22
24
|
easing?: TransitionEasing;
|
|
23
25
|
/** Direction of transition */
|
|
24
26
|
direction?: TransitionDirection;
|
|
27
|
+
/** Navigation stack action (default: follows direction, except 'none' keeps push behavior for compatibility) */
|
|
28
|
+
navigationAction?: NavigationAction;
|
|
25
29
|
/** Which elements to animate (default: 'all') */
|
|
26
30
|
targets?: TransitionTarget[];
|
|
27
31
|
/** Custom animation keyframes for entering element */
|
|
@@ -234,6 +238,7 @@ declare class TransitionController {
|
|
|
234
238
|
* Main navigation method
|
|
235
239
|
*/
|
|
236
240
|
navigate(enteringEl: HTMLElement, config?: TransitionConfig): Promise<TransitionResult>;
|
|
241
|
+
private resolveNavigationAction;
|
|
237
242
|
/**
|
|
238
243
|
* Navigate between two known page states
|
|
239
244
|
*/
|
|
@@ -387,6 +392,10 @@ declare class CapRouterOutlet extends HTMLElement {
|
|
|
387
392
|
* Enable, disable, or auto-detect edge swipe-back gesture.
|
|
388
393
|
*/
|
|
389
394
|
setSwipeGesture(value: SwipeGestureOption): void;
|
|
395
|
+
/**
|
|
396
|
+
* Set the navigation stack action and animation direction for the next router-driven navigation.
|
|
397
|
+
*/
|
|
398
|
+
setNavigation(action: NavigationAction, direction?: TransitionDirection): void;
|
|
390
399
|
/**
|
|
391
400
|
* Get the transition controller for advanced usage
|
|
392
401
|
*/
|
|
@@ -747,4 +756,4 @@ declare global {
|
|
|
747
756
|
}
|
|
748
757
|
}
|
|
749
758
|
|
|
750
|
-
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 };
|
|
759
|
+
export { ANDROID_DURATION, ANDROID_EASING, type AnimationBuilder, CapContent, CapFooter, CapHeader, CapPage, CapRouterOutlet, IOS_DURATION, IOS_EASING, type NativePlatform, type NativePlatformInfo, type NavigationAction, 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 };
|
package/dist/index.js
CHANGED
|
@@ -1019,19 +1019,24 @@ var init_transition_controller = __esm({
|
|
|
1019
1019
|
* Replace all pages with a new root
|
|
1020
1020
|
*/
|
|
1021
1021
|
async setRoot(enteringEl, config = {}) {
|
|
1022
|
-
return this.navigate(enteringEl, {
|
|
1022
|
+
return this.navigate(enteringEl, {
|
|
1023
|
+
...config,
|
|
1024
|
+
direction: config.direction ?? "root",
|
|
1025
|
+
navigationAction: "root"
|
|
1026
|
+
});
|
|
1023
1027
|
}
|
|
1024
1028
|
/**
|
|
1025
1029
|
* Main navigation method
|
|
1026
1030
|
*/
|
|
1027
1031
|
async navigate(enteringEl, config = {}) {
|
|
1028
1032
|
const direction = config.direction || "forward";
|
|
1033
|
+
const navigationAction = this.resolveNavigationAction(direction, config.navigationAction);
|
|
1029
1034
|
const enteringState = this.createPageState(enteringEl);
|
|
1030
1035
|
const leavingState = this.currentPage;
|
|
1031
1036
|
return this.navigateWithStates(enteringState, leavingState, config, () => {
|
|
1032
|
-
if (
|
|
1037
|
+
if (navigationAction === "root") {
|
|
1033
1038
|
this.pageStack = [enteringState];
|
|
1034
|
-
} else if (
|
|
1039
|
+
} else if (navigationAction === "back" && this.pageStack.length > 0) {
|
|
1035
1040
|
this.pageStack.pop();
|
|
1036
1041
|
const staleEnteringState = this.pageStack.pop();
|
|
1037
1042
|
if (staleEnteringState && staleEnteringState.element !== enteringState.element) {
|
|
@@ -1039,11 +1044,27 @@ var init_transition_controller = __esm({
|
|
|
1039
1044
|
this.lifecycleCallbacks.delete(staleEnteringState.id);
|
|
1040
1045
|
}
|
|
1041
1046
|
this.pageStack.push(enteringState);
|
|
1047
|
+
} else if (navigationAction === "none" && this.pageStack.length > 0) {
|
|
1048
|
+
const staleState = this.pageStack.pop();
|
|
1049
|
+
if (staleState && staleState.element !== enteringState.element) {
|
|
1050
|
+
staleState.element.remove();
|
|
1051
|
+
this.lifecycleCallbacks.delete(staleState.id);
|
|
1052
|
+
}
|
|
1053
|
+
this.pageStack.push(enteringState);
|
|
1042
1054
|
} else {
|
|
1043
1055
|
this.pageStack.push(enteringState);
|
|
1044
1056
|
}
|
|
1045
1057
|
});
|
|
1046
1058
|
}
|
|
1059
|
+
resolveNavigationAction(direction, navigationAction) {
|
|
1060
|
+
if (navigationAction) {
|
|
1061
|
+
return navigationAction;
|
|
1062
|
+
}
|
|
1063
|
+
if (direction === "root" || direction === "back") {
|
|
1064
|
+
return direction;
|
|
1065
|
+
}
|
|
1066
|
+
return "forward";
|
|
1067
|
+
}
|
|
1047
1068
|
/**
|
|
1048
1069
|
* Navigate between two known page states
|
|
1049
1070
|
*/
|
|
@@ -1328,12 +1349,33 @@ var init_transition_controller = __esm({
|
|
|
1328
1349
|
}
|
|
1329
1350
|
});
|
|
1330
1351
|
|
|
1352
|
+
// src/core/navigation.ts
|
|
1353
|
+
function getDefaultNavigationDirection(action) {
|
|
1354
|
+
return action;
|
|
1355
|
+
}
|
|
1356
|
+
function setOutletDirectionIntent(outlet, direction) {
|
|
1357
|
+
const element = outlet;
|
|
1358
|
+
element.dataset.direction = direction;
|
|
1359
|
+
delete element.dataset.navigationAction;
|
|
1360
|
+
}
|
|
1361
|
+
function setOutletNavigationIntent(outlet, action, direction = getDefaultNavigationDirection(action)) {
|
|
1362
|
+
const element = outlet;
|
|
1363
|
+
element.dataset.navigationAction = action;
|
|
1364
|
+
element.dataset.direction = direction;
|
|
1365
|
+
}
|
|
1366
|
+
var init_navigation = __esm({
|
|
1367
|
+
"src/core/navigation.ts"() {
|
|
1368
|
+
"use strict";
|
|
1369
|
+
}
|
|
1370
|
+
});
|
|
1371
|
+
|
|
1331
1372
|
// src/components/cap-router-outlet.ts
|
|
1332
1373
|
var CapRouterOutlet;
|
|
1333
1374
|
var init_cap_router_outlet = __esm({
|
|
1334
1375
|
"src/components/cap-router-outlet.ts"() {
|
|
1335
1376
|
"use strict";
|
|
1336
1377
|
init_native_platform();
|
|
1378
|
+
init_navigation();
|
|
1337
1379
|
init_transition_controller();
|
|
1338
1380
|
CapRouterOutlet = class extends HTMLElement {
|
|
1339
1381
|
controller;
|
|
@@ -1501,20 +1543,29 @@ var init_cap_router_outlet = __esm({
|
|
|
1501
1543
|
*/
|
|
1502
1544
|
async handleNewPage(page) {
|
|
1503
1545
|
const outletDirection = this.dataset.direction;
|
|
1546
|
+
const outletNavigationAction = this.dataset.navigationAction;
|
|
1504
1547
|
const explicitDirection = page.dataset.direction || outletDirection;
|
|
1548
|
+
const explicitNavigationAction = page.dataset.navigationAction || outletNavigationAction;
|
|
1505
1549
|
const direction = this.resolveNavigationDirection(explicitDirection);
|
|
1506
1550
|
if (outletDirection) {
|
|
1507
1551
|
delete this.dataset.direction;
|
|
1508
1552
|
}
|
|
1553
|
+
if (outletNavigationAction) {
|
|
1554
|
+
delete this.dataset.navigationAction;
|
|
1555
|
+
}
|
|
1509
1556
|
const skipTransition = this.skipNextHistoryBackTransition && direction === "back";
|
|
1510
1557
|
this.skipNextHistoryBackTransition = false;
|
|
1511
1558
|
const hadPageBefore = this.controller.stack.length > 0;
|
|
1512
1559
|
this.stylePageForTransition(page);
|
|
1513
1560
|
this.pendingPage = page;
|
|
1514
1561
|
try {
|
|
1515
|
-
const result = await this.controller.navigate(page, {
|
|
1562
|
+
const result = await this.controller.navigate(page, {
|
|
1563
|
+
direction,
|
|
1564
|
+
navigationAction: explicitNavigationAction,
|
|
1565
|
+
duration: skipTransition ? 0 : void 0
|
|
1566
|
+
});
|
|
1516
1567
|
if (result.success) {
|
|
1517
|
-
this.recordCompletedNavigation(direction, { hadPageBefore });
|
|
1568
|
+
this.recordCompletedNavigation(explicitNavigationAction ?? direction, { hadPageBefore });
|
|
1518
1569
|
}
|
|
1519
1570
|
} finally {
|
|
1520
1571
|
this.pendingPage = null;
|
|
@@ -1643,6 +1694,12 @@ var init_cap_router_outlet = __esm({
|
|
|
1643
1694
|
this.updateSwipeGestureListeners();
|
|
1644
1695
|
}
|
|
1645
1696
|
}
|
|
1697
|
+
/**
|
|
1698
|
+
* Set the navigation stack action and animation direction for the next router-driven navigation.
|
|
1699
|
+
*/
|
|
1700
|
+
setNavigation(action, direction = getDefaultNavigationDirection(action)) {
|
|
1701
|
+
setOutletNavigationIntent(this, action, direction);
|
|
1702
|
+
}
|
|
1646
1703
|
/**
|
|
1647
1704
|
* Get the transition controller for advanced usage
|
|
1648
1705
|
*/
|
|
@@ -2041,7 +2098,7 @@ var init_cap_router_outlet = __esm({
|
|
|
2041
2098
|
}
|
|
2042
2099
|
if (shouldUseHistory) {
|
|
2043
2100
|
this.skipNextHistoryBackTransition = true;
|
|
2044
|
-
this
|
|
2101
|
+
setOutletDirectionIntent(this, "back");
|
|
2045
2102
|
window.history.back();
|
|
2046
2103
|
return;
|
|
2047
2104
|
}
|