@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/svelte/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
|
/** Whether the edge swipe-back gesture is enabled, disabled, or native-detected */
|
|
@@ -20,6 +22,8 @@ interface TransitionConfig {
|
|
|
20
22
|
easing?: TransitionEasing;
|
|
21
23
|
/** Direction of transition */
|
|
22
24
|
direction?: TransitionDirection;
|
|
25
|
+
/** Navigation stack action (default: follows direction, except 'none' keeps push behavior for compatibility) */
|
|
26
|
+
navigationAction?: NavigationAction;
|
|
23
27
|
/** Which elements to animate (default: 'all') */
|
|
24
28
|
targets?: TransitionTarget[];
|
|
25
29
|
/** Custom animation keyframes for entering element */
|
|
@@ -186,6 +190,7 @@ declare class TransitionController {
|
|
|
186
190
|
* Main navigation method
|
|
187
191
|
*/
|
|
188
192
|
navigate(enteringEl: HTMLElement, config?: TransitionConfig): Promise<TransitionResult>;
|
|
193
|
+
private resolveNavigationAction;
|
|
189
194
|
/**
|
|
190
195
|
* Navigate between two known page states
|
|
191
196
|
*/
|
|
@@ -261,6 +266,10 @@ declare function getController(): TransitionController;
|
|
|
261
266
|
*/
|
|
262
267
|
declare function getDirection(): TransitionDirection;
|
|
263
268
|
declare function setDirection(direction: TransitionDirection): void;
|
|
269
|
+
/**
|
|
270
|
+
* Set the navigation action and animation direction for the next router navigation.
|
|
271
|
+
*/
|
|
272
|
+
declare function setNavigation(action: NavigationAction, direction?: TransitionDirection): void;
|
|
264
273
|
/**
|
|
265
274
|
* Helper for Svelte actions - use on cap-router-outlet
|
|
266
275
|
*/
|
|
@@ -295,4 +304,4 @@ declare function navigateWithTransition(navigate: (to: string) => void, to: stri
|
|
|
295
304
|
*/
|
|
296
305
|
declare function createTransitionNavigate(navigate: (to: string) => void): (to: string, direction?: TransitionDirection) => void;
|
|
297
306
|
|
|
298
|
-
export { type NavigationEvent, type SwipeGestureOption, TransitionController, type TransitionDirection, type TransitionGlobalConfig, createTransitionNavigate, getController, getDirection, initTransitions, navigateWithTransition, page, routerOutlet, setDirection };
|
|
307
|
+
export { type NavigationAction, type NavigationEvent, type SwipeGestureOption, TransitionController, type TransitionDirection, type TransitionGlobalConfig, createTransitionNavigate, getController, getDirection, initTransitions, navigateWithTransition, page, routerOutlet, setDirection, setNavigation };
|
package/dist/svelte/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
|
/** Whether the edge swipe-back gesture is enabled, disabled, or native-detected */
|
|
@@ -20,6 +22,8 @@ interface TransitionConfig {
|
|
|
20
22
|
easing?: TransitionEasing;
|
|
21
23
|
/** Direction of transition */
|
|
22
24
|
direction?: TransitionDirection;
|
|
25
|
+
/** Navigation stack action (default: follows direction, except 'none' keeps push behavior for compatibility) */
|
|
26
|
+
navigationAction?: NavigationAction;
|
|
23
27
|
/** Which elements to animate (default: 'all') */
|
|
24
28
|
targets?: TransitionTarget[];
|
|
25
29
|
/** Custom animation keyframes for entering element */
|
|
@@ -186,6 +190,7 @@ declare class TransitionController {
|
|
|
186
190
|
* Main navigation method
|
|
187
191
|
*/
|
|
188
192
|
navigate(enteringEl: HTMLElement, config?: TransitionConfig): Promise<TransitionResult>;
|
|
193
|
+
private resolveNavigationAction;
|
|
189
194
|
/**
|
|
190
195
|
* Navigate between two known page states
|
|
191
196
|
*/
|
|
@@ -261,6 +266,10 @@ declare function getController(): TransitionController;
|
|
|
261
266
|
*/
|
|
262
267
|
declare function getDirection(): TransitionDirection;
|
|
263
268
|
declare function setDirection(direction: TransitionDirection): void;
|
|
269
|
+
/**
|
|
270
|
+
* Set the navigation action and animation direction for the next router navigation.
|
|
271
|
+
*/
|
|
272
|
+
declare function setNavigation(action: NavigationAction, direction?: TransitionDirection): void;
|
|
264
273
|
/**
|
|
265
274
|
* Helper for Svelte actions - use on cap-router-outlet
|
|
266
275
|
*/
|
|
@@ -295,4 +304,4 @@ declare function navigateWithTransition(navigate: (to: string) => void, to: stri
|
|
|
295
304
|
*/
|
|
296
305
|
declare function createTransitionNavigate(navigate: (to: string) => void): (to: string, direction?: TransitionDirection) => void;
|
|
297
306
|
|
|
298
|
-
export { type NavigationEvent, type SwipeGestureOption, TransitionController, type TransitionDirection, type TransitionGlobalConfig, createTransitionNavigate, getController, getDirection, initTransitions, navigateWithTransition, page, routerOutlet, setDirection };
|
|
307
|
+
export { type NavigationAction, type NavigationEvent, type SwipeGestureOption, TransitionController, type TransitionDirection, type TransitionGlobalConfig, createTransitionNavigate, getController, getDirection, initTransitions, navigateWithTransition, page, routerOutlet, setDirection, setNavigation };
|
package/dist/svelte/index.js
CHANGED
|
@@ -28,10 +28,26 @@ __export(index_exports, {
|
|
|
28
28
|
navigateWithTransition: () => navigateWithTransition,
|
|
29
29
|
page: () => page,
|
|
30
30
|
routerOutlet: () => routerOutlet,
|
|
31
|
-
setDirection: () => setDirection
|
|
31
|
+
setDirection: () => setDirection,
|
|
32
|
+
setNavigation: () => setNavigation
|
|
32
33
|
});
|
|
33
34
|
module.exports = __toCommonJS(index_exports);
|
|
34
35
|
|
|
36
|
+
// src/core/navigation.ts
|
|
37
|
+
function getDefaultNavigationDirection(action) {
|
|
38
|
+
return action;
|
|
39
|
+
}
|
|
40
|
+
function setOutletDirectionIntent(outlet, direction) {
|
|
41
|
+
const element = outlet;
|
|
42
|
+
element.dataset.direction = direction;
|
|
43
|
+
delete element.dataset.navigationAction;
|
|
44
|
+
}
|
|
45
|
+
function setOutletNavigationIntent(outlet, action, direction = getDefaultNavigationDirection(action)) {
|
|
46
|
+
const element = outlet;
|
|
47
|
+
element.dataset.navigationAction = action;
|
|
48
|
+
element.dataset.direction = direction;
|
|
49
|
+
}
|
|
50
|
+
|
|
35
51
|
// src/core/animations.ts
|
|
36
52
|
var IOS_EASING = "cubic-bezier(0.32, 0.72, 0, 1)";
|
|
37
53
|
var ANDROID_EASING = "cubic-bezier(0.36, 0.66, 0.04, 1)";
|
|
@@ -906,19 +922,24 @@ var TransitionController = class {
|
|
|
906
922
|
* Replace all pages with a new root
|
|
907
923
|
*/
|
|
908
924
|
async setRoot(enteringEl, config = {}) {
|
|
909
|
-
return this.navigate(enteringEl, {
|
|
925
|
+
return this.navigate(enteringEl, {
|
|
926
|
+
...config,
|
|
927
|
+
direction: config.direction ?? "root",
|
|
928
|
+
navigationAction: "root"
|
|
929
|
+
});
|
|
910
930
|
}
|
|
911
931
|
/**
|
|
912
932
|
* Main navigation method
|
|
913
933
|
*/
|
|
914
934
|
async navigate(enteringEl, config = {}) {
|
|
915
935
|
const direction = config.direction || "forward";
|
|
936
|
+
const navigationAction = this.resolveNavigationAction(direction, config.navigationAction);
|
|
916
937
|
const enteringState = this.createPageState(enteringEl);
|
|
917
938
|
const leavingState = this.currentPage;
|
|
918
939
|
return this.navigateWithStates(enteringState, leavingState, config, () => {
|
|
919
|
-
if (
|
|
940
|
+
if (navigationAction === "root") {
|
|
920
941
|
this.pageStack = [enteringState];
|
|
921
|
-
} else if (
|
|
942
|
+
} else if (navigationAction === "back" && this.pageStack.length > 0) {
|
|
922
943
|
this.pageStack.pop();
|
|
923
944
|
const staleEnteringState = this.pageStack.pop();
|
|
924
945
|
if (staleEnteringState && staleEnteringState.element !== enteringState.element) {
|
|
@@ -926,11 +947,27 @@ var TransitionController = class {
|
|
|
926
947
|
this.lifecycleCallbacks.delete(staleEnteringState.id);
|
|
927
948
|
}
|
|
928
949
|
this.pageStack.push(enteringState);
|
|
950
|
+
} else if (navigationAction === "none" && this.pageStack.length > 0) {
|
|
951
|
+
const staleState = this.pageStack.pop();
|
|
952
|
+
if (staleState && staleState.element !== enteringState.element) {
|
|
953
|
+
staleState.element.remove();
|
|
954
|
+
this.lifecycleCallbacks.delete(staleState.id);
|
|
955
|
+
}
|
|
956
|
+
this.pageStack.push(enteringState);
|
|
929
957
|
} else {
|
|
930
958
|
this.pageStack.push(enteringState);
|
|
931
959
|
}
|
|
932
960
|
});
|
|
933
961
|
}
|
|
962
|
+
resolveNavigationAction(direction, navigationAction) {
|
|
963
|
+
if (navigationAction) {
|
|
964
|
+
return navigationAction;
|
|
965
|
+
}
|
|
966
|
+
if (direction === "root" || direction === "back") {
|
|
967
|
+
return direction;
|
|
968
|
+
}
|
|
969
|
+
return "forward";
|
|
970
|
+
}
|
|
934
971
|
/**
|
|
935
972
|
* Navigate between two known page states
|
|
936
973
|
*/
|
|
@@ -1406,20 +1443,29 @@ var CapRouterOutlet = class extends HTMLElement {
|
|
|
1406
1443
|
*/
|
|
1407
1444
|
async handleNewPage(page2) {
|
|
1408
1445
|
const outletDirection = this.dataset.direction;
|
|
1446
|
+
const outletNavigationAction = this.dataset.navigationAction;
|
|
1409
1447
|
const explicitDirection = page2.dataset.direction || outletDirection;
|
|
1448
|
+
const explicitNavigationAction = page2.dataset.navigationAction || outletNavigationAction;
|
|
1410
1449
|
const direction = this.resolveNavigationDirection(explicitDirection);
|
|
1411
1450
|
if (outletDirection) {
|
|
1412
1451
|
delete this.dataset.direction;
|
|
1413
1452
|
}
|
|
1453
|
+
if (outletNavigationAction) {
|
|
1454
|
+
delete this.dataset.navigationAction;
|
|
1455
|
+
}
|
|
1414
1456
|
const skipTransition = this.skipNextHistoryBackTransition && direction === "back";
|
|
1415
1457
|
this.skipNextHistoryBackTransition = false;
|
|
1416
1458
|
const hadPageBefore = this.controller.stack.length > 0;
|
|
1417
1459
|
this.stylePageForTransition(page2);
|
|
1418
1460
|
this.pendingPage = page2;
|
|
1419
1461
|
try {
|
|
1420
|
-
const result = await this.controller.navigate(page2, {
|
|
1462
|
+
const result = await this.controller.navigate(page2, {
|
|
1463
|
+
direction,
|
|
1464
|
+
navigationAction: explicitNavigationAction,
|
|
1465
|
+
duration: skipTransition ? 0 : void 0
|
|
1466
|
+
});
|
|
1421
1467
|
if (result.success) {
|
|
1422
|
-
this.recordCompletedNavigation(direction, { hadPageBefore });
|
|
1468
|
+
this.recordCompletedNavigation(explicitNavigationAction ?? direction, { hadPageBefore });
|
|
1423
1469
|
}
|
|
1424
1470
|
} finally {
|
|
1425
1471
|
this.pendingPage = null;
|
|
@@ -1548,6 +1594,12 @@ var CapRouterOutlet = class extends HTMLElement {
|
|
|
1548
1594
|
this.updateSwipeGestureListeners();
|
|
1549
1595
|
}
|
|
1550
1596
|
}
|
|
1597
|
+
/**
|
|
1598
|
+
* Set the navigation stack action and animation direction for the next router-driven navigation.
|
|
1599
|
+
*/
|
|
1600
|
+
setNavigation(action, direction = getDefaultNavigationDirection(action)) {
|
|
1601
|
+
setOutletNavigationIntent(this, action, direction);
|
|
1602
|
+
}
|
|
1551
1603
|
/**
|
|
1552
1604
|
* Get the transition controller for advanced usage
|
|
1553
1605
|
*/
|
|
@@ -1946,7 +1998,7 @@ var CapRouterOutlet = class extends HTMLElement {
|
|
|
1946
1998
|
}
|
|
1947
1999
|
if (shouldUseHistory) {
|
|
1948
2000
|
this.skipNextHistoryBackTransition = true;
|
|
1949
|
-
this
|
|
2001
|
+
setOutletDirectionIntent(this, "back");
|
|
1950
2002
|
window.history.back();
|
|
1951
2003
|
return;
|
|
1952
2004
|
}
|
|
@@ -2382,7 +2434,15 @@ function setDirection(direction) {
|
|
|
2382
2434
|
globalDirection = direction;
|
|
2383
2435
|
if (typeof document !== "undefined") {
|
|
2384
2436
|
for (const outlet of document.querySelectorAll("cap-router-outlet")) {
|
|
2385
|
-
outlet
|
|
2437
|
+
setOutletDirectionIntent(outlet, direction);
|
|
2438
|
+
}
|
|
2439
|
+
}
|
|
2440
|
+
}
|
|
2441
|
+
function setNavigation(action, direction = getDefaultNavigationDirection(action)) {
|
|
2442
|
+
globalDirection = direction;
|
|
2443
|
+
if (typeof document !== "undefined") {
|
|
2444
|
+
for (const outlet of document.querySelectorAll("cap-router-outlet")) {
|
|
2445
|
+
setOutletNavigationIntent(outlet, action, direction);
|
|
2386
2446
|
}
|
|
2387
2447
|
}
|
|
2388
2448
|
}
|
|
@@ -2462,6 +2522,7 @@ function createTransitionNavigate(navigate) {
|
|
|
2462
2522
|
navigateWithTransition,
|
|
2463
2523
|
page,
|
|
2464
2524
|
routerOutlet,
|
|
2465
|
-
setDirection
|
|
2525
|
+
setDirection,
|
|
2526
|
+
setNavigation
|
|
2466
2527
|
});
|
|
2467
2528
|
//# sourceMappingURL=index.js.map
|