@stacknav/core 0.3.1 → 0.4.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.
Files changed (56) hide show
  1. package/README.md +111 -59
  2. package/dist/animate.d.ts +18 -0
  3. package/dist/animate.d.ts.map +1 -1
  4. package/dist/animate.js +44 -2
  5. package/dist/animate.js.map +1 -1
  6. package/dist/css-vars.d.ts +3 -3
  7. package/dist/css-vars.d.ts.map +1 -1
  8. package/dist/css-vars.js +47 -4
  9. package/dist/css-vars.js.map +1 -1
  10. package/dist/history-adapter.d.ts +0 -1
  11. package/dist/history-adapter.d.ts.map +1 -1
  12. package/dist/history-adapter.js +1 -5
  13. package/dist/history-adapter.js.map +1 -1
  14. package/dist/index.d.ts +27 -18
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +38 -15
  17. package/dist/index.js.map +1 -1
  18. package/dist/native-transition.d.ts +93 -0
  19. package/dist/native-transition.d.ts.map +1 -0
  20. package/dist/{ios-transition.js → native-transition.js} +42 -25
  21. package/dist/native-transition.js.map +1 -0
  22. package/dist/navigation-stack.d.ts +3 -0
  23. package/dist/navigation-stack.d.ts.map +1 -1
  24. package/dist/navigation-stack.js +42 -3
  25. package/dist/navigation-stack.js.map +1 -1
  26. package/dist/platform.d.ts +6 -0
  27. package/dist/platform.d.ts.map +1 -0
  28. package/dist/platform.js +22 -0
  29. package/dist/platform.js.map +1 -0
  30. package/dist/stacknav.css +4 -13
  31. package/dist/styles.d.ts +5 -9
  32. package/dist/styles.d.ts.map +1 -1
  33. package/dist/styles.js +6 -12
  34. package/dist/styles.js.map +1 -1
  35. package/dist/swipe-back.d.ts +4 -0
  36. package/dist/swipe-back.d.ts.map +1 -0
  37. package/dist/swipe-back.js +31 -0
  38. package/dist/swipe-back.js.map +1 -0
  39. package/package.json +3 -2
  40. package/src/animate.ts +47 -4
  41. package/src/css-vars.ts +43 -4
  42. package/src/history-adapter.ts +1 -5
  43. package/src/index.ts +49 -24
  44. package/src/{ios-transition.ts → native-transition.ts} +67 -35
  45. package/src/navigation-stack.ts +30 -3
  46. package/src/platform.ts +23 -0
  47. package/src/styles.ts +6 -12
  48. package/src/swipe-back.ts +35 -0
  49. package/dist/edge-pan-gesture.d.ts +0 -36
  50. package/dist/edge-pan-gesture.d.ts.map +0 -1
  51. package/dist/edge-pan-gesture.js +0 -155
  52. package/dist/edge-pan-gesture.js.map +0 -1
  53. package/dist/ios-transition.d.ts +0 -61
  54. package/dist/ios-transition.d.ts.map +0 -1
  55. package/dist/ios-transition.js.map +0 -1
  56. package/src/edge-pan-gesture.ts +0 -190
package/dist/index.d.ts CHANGED
@@ -1,34 +1,43 @@
1
+ export type { SwipeBackMode } from './swipe-back.ts';
1
2
  export { NavigationStack } from './navigation-stack.ts';
2
3
  export type { StackEntry, Transition, TransitionKind, NavigationSource, MountOptions, NavigationStackOptions, InteractivePopHandle, SettleInput, StackEvents, PushEvent, PopEvent, ReplaceEvent, ResetEvent, TransitionEvent, ProgressEvent, } from './navigation-stack.ts';
3
- export { createIOSTransition, IOS_TRANSITION_CSS_VARS } from './ios-transition.ts';
4
- export type { IOSTransition, IOSTransitionOptions } from './ios-transition.ts';
4
+ export { createNativeTransition, nativeTransitionPreset, NATIVE_TRANSITION_CSS_VARS } from './native-transition.ts';
5
+ export type { NativeTransition, NativeTransitionOptions, NativeTransitionPreset } from './native-transition.ts';
5
6
  export { cssVars, parseTime, parseNumber, parseRatio, parseEasing } from './css-vars.ts';
6
7
  export type { CSSVarReader } from './css-vars.ts';
7
- export { createEdgePanGesture } from './edge-pan-gesture.ts';
8
- export type { EdgePanGesture, EdgePanGestureOptions } from './edge-pan-gesture.ts';
9
- export { attachBrowserHistory, isIOSBrowser } from './history-adapter.ts';
8
+ export { attachBrowserHistory } from './history-adapter.ts';
10
9
  export type { BrowserHistoryOptions } from './history-adapter.ts';
11
- export { cubicBezier, easings, cssEasing, cssDuration, tween, commitStyles, animationsFinished, prefersReducedMotion } from './animate.ts';
10
+ export { detectPlatform, isIOSBrowser, isAndroidBrowser } from './platform.ts';
11
+ export type { Platform } from './platform.ts';
12
+ export { cubicBezier, linearEasing, easings, cssEasing, cssDuration, tween, commitStyles, animationsFinished, prefersReducedMotion, matchesMedia, isTouchPrimary } from './animate.ts';
12
13
  export type { Easing, TweenOptions, CancellableTween } from './animate.ts';
13
14
  export { resolveDirection, createDirectionResolver, defaultStrategies, fromHint, fromHistory, fromStack, fromLevel, fromTree, always, segmentsOf, } from './direction.ts';
14
15
  export type { Direction, DirectionOpinion, DirectionStrategy, DirectionResolver, NavigationContext, NavigationTrigger, RouteRef, LevelOptions, TreeOptions, } from './direction.ts';
15
16
  export { STACKNAV_CSS, STACKNAV_STYLE_ID, injectStyles } from './styles.ts';
16
17
  import { NavigationStack } from './navigation-stack.ts';
17
- import { type IOSTransition, type IOSTransitionOptions } from './ios-transition.ts';
18
- import { type EdgePanGesture, type EdgePanGestureOptions } from './edge-pan-gesture.ts';
19
- export interface IOSStackOptions {
18
+ import { type NativeTransition, type NativeTransitionOptions } from './native-transition.ts';
19
+ import { type SwipeBackMode } from './swipe-back.ts';
20
+ export interface NativeStackOptions {
20
21
  container: HTMLElement;
21
- transition?: Partial<IOSTransitionOptions>;
22
- gesture?: Partial<EdgePanGestureOptions>;
22
+ transition?: Partial<NativeTransitionOptions>;
23
+ /** Default browser. Disabled requests document-wide browser swipe suppression. */
24
+ swipeBack?: SwipeBackMode;
23
25
  }
24
- export interface IOSStack extends NavigationStack {
25
- transition: IOSTransition;
26
- gesture: EdgePanGesture;
26
+ export interface NativeStack extends NavigationStack {
27
+ transition: NativeTransition;
28
+ readonly swipeBack: SwipeBackMode;
29
+ /** Changes the policy without replacing pages or changing browser history. */
30
+ setSwipeBack(mode: SwipeBackMode): void;
27
31
  }
28
32
  /**
29
- * Wires the three pieces together in one call: a stack in `container`, the iOS
30
- * transition, and the edge-pan gesture. The gesture is exposed as
31
- * `stack.gesture`, and destroying the stack detaches it.
33
+ * Wires the two pieces together in one call: a stack in `container` and the
34
+ * platform's native transition. The browser keeps the back gesture unless
35
+ * `disabled` asks for suppression; destroying releases that request.
36
+ *
37
+ * There is no gesture recognizer here on purpose. In a browser tab the browser
38
+ * already owns the edge and will not give it up, so a second recognizer reads
39
+ * as two backs at once. Apps that own the edge -- an installed PWA, a native
40
+ * webview -- can drive `beginInteractivePop()` from their own pointer handling.
32
41
  */
33
- export declare function createIOSStack({ container, transition, gesture }: IOSStackOptions): IOSStack;
42
+ export declare function createNativeStack({ container, transition, swipeBack }: NativeStackOptions): NativeStack;
34
43
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,YAAY,EACV,UAAU,EACV,UAAU,EACV,cAAc,EACd,gBAAgB,EAChB,YAAY,EACZ,sBAAsB,EACtB,oBAAoB,EACpB,WAAW,EACX,WAAW,EACX,SAAS,EACT,QAAQ,EACR,YAAY,EACZ,UAAU,EACV,eAAe,EACf,aAAa,GACd,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AACnF,YAAY,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC/E,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACzF,YAAY,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,YAAY,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AACnF,OAAO,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAC1E,YAAY,EAAE,qBAAqB,EAAE,MAAM,sBAAsB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AAW,EACX,SAAS,EACT,SAAS,EACT,QAAQ,EACR,MAAM,EACN,UAAU,GACX,MAAM,gBAAgB,CAAC;AACxB,YAAY,EACV,SAAS,EACT,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EACjB,QAAQ,EACR,YAAY,EACZ,WAAW,GACZ,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE5E,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAA0B,KAAK,gBAAgB,EAAE,KAAK,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAErH,OAAO,EAAwB,KAAK,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAE3E,MAAM,WAAW,kBAAkB;IACjC,SAAS,EAAE,WAAW,CAAC;IACvB,UAAU,CAAC,EAAE,OAAO,CAAC,uBAAuB,CAAC,CAAC;IAC9C,kFAAkF;IAClF,SAAS,CAAC,EAAE,aAAa,CAAC;CAC3B;AAED,MAAM,WAAW,WAAY,SAAQ,eAAe;IAClD,UAAU,EAAE,gBAAgB,CAAC;IAC7B,QAAQ,CAAC,SAAS,EAAE,aAAa,CAAC;IAClC,8EAA8E;IAC9E,YAAY,CAAC,IAAI,EAAE,aAAa,GAAG,IAAI,CAAC;CACzC;AAED;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAAC,EAAE,SAAS,EAAE,UAAe,EAAE,SAAqB,EAAE,EAAE,kBAAkB,GAAG,WAAW,CA2BxH"}
package/dist/index.js CHANGED
@@ -1,28 +1,51 @@
1
1
  export { NavigationStack } from "./navigation-stack.js";
2
- export { createIOSTransition, IOS_TRANSITION_CSS_VARS } from "./ios-transition.js";
2
+ export { createNativeTransition, nativeTransitionPreset, NATIVE_TRANSITION_CSS_VARS } from "./native-transition.js";
3
3
  export { cssVars, parseTime, parseNumber, parseRatio, parseEasing } from "./css-vars.js";
4
- export { createEdgePanGesture } from "./edge-pan-gesture.js";
5
- export { attachBrowserHistory, isIOSBrowser } from "./history-adapter.js";
6
- export { cubicBezier, easings, cssEasing, cssDuration, tween, commitStyles, animationsFinished, prefersReducedMotion } from "./animate.js";
4
+ export { attachBrowserHistory } from "./history-adapter.js";
5
+ export { detectPlatform, isIOSBrowser, isAndroidBrowser } from "./platform.js";
6
+ export { cubicBezier, linearEasing, easings, cssEasing, cssDuration, tween, commitStyles, animationsFinished, prefersReducedMotion, matchesMedia, isTouchPrimary } from "./animate.js";
7
7
  export { resolveDirection, createDirectionResolver, defaultStrategies, fromHint, fromHistory, fromStack, fromLevel, fromTree, always, segmentsOf, } from "./direction.js";
8
8
  export { STACKNAV_CSS, STACKNAV_STYLE_ID, injectStyles } from "./styles.js";
9
9
  import { NavigationStack } from "./navigation-stack.js";
10
- import { createIOSTransition } from "./ios-transition.js";
11
- import { createEdgePanGesture } from "./edge-pan-gesture.js";
10
+ import { createNativeTransition } from "./native-transition.js";
11
+ import { suppressBrowserSwipe } from "./swipe-back.js";
12
12
  /**
13
- * Wires the three pieces together in one call: a stack in `container`, the iOS
14
- * transition, and the edge-pan gesture. The gesture is exposed as
15
- * `stack.gesture`, and destroying the stack detaches it.
13
+ * Wires the two pieces together in one call: a stack in `container` and the
14
+ * platform's native transition. The browser keeps the back gesture unless
15
+ * `disabled` asks for suppression; destroying releases that request.
16
+ *
17
+ * There is no gesture recognizer here on purpose. In a browser tab the browser
18
+ * already owns the edge and will not give it up, so a second recognizer reads
19
+ * as two backs at once. Apps that own the edge -- an installed PWA, a native
20
+ * webview -- can drive `beginInteractivePop()` from their own pointer handling.
16
21
  */
17
- export function createIOSStack({ container, transition = {}, gesture = {} }) {
18
- const t = createIOSTransition(transition);
19
- const g = createEdgePanGesture(gesture);
22
+ export function createNativeStack({ container, transition = {}, swipeBack = 'browser' }) {
23
+ const t = createNativeTransition(transition);
20
24
  const stack = new NavigationStack({ container, transition: t });
21
- g.attach(stack);
22
- stack.gesture = g;
25
+ let mode;
26
+ let release;
27
+ let destroyed = false;
28
+ Object.defineProperty(stack, 'swipeBack', { get: () => mode });
29
+ stack.setSwipeBack = (next) => {
30
+ if (destroyed || next === mode)
31
+ return;
32
+ if (next !== 'browser' && next !== 'disabled')
33
+ throw new TypeError('Invalid swipeBack mode');
34
+ if (next === 'browser') {
35
+ release?.();
36
+ release = undefined;
37
+ }
38
+ else {
39
+ release ??= suppressBrowserSwipe(container);
40
+ }
41
+ mode = next;
42
+ };
43
+ stack.setSwipeBack(swipeBack);
23
44
  const destroy = stack.destroy.bind(stack);
24
45
  stack.destroy = () => {
25
- g.detach();
46
+ destroyed = true;
47
+ release?.();
48
+ release = undefined;
26
49
  destroy();
27
50
  };
28
51
  return stack;
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAkBxD,OAAO,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAEnF,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEzF,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAE7D,OAAO,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAE1E,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,KAAK,EAAE,YAAY,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAE3I,OAAO,EACL,gBAAgB,EAChB,uBAAuB,EACvB,iBAAiB,EACjB,QAAQ,EACR,WAAW,EACX,SAAS,EACT,SAAS,EACT,QAAQ,EACR,MAAM,EACN,UAAU,GACX,MAAM,gBAAgB,CAAC;AAYxB,OAAO,EAAE,YAAY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AAK,SAAS,IAAI,IAAI,KAAK,UAAU;YAAE,MAAM,IAAI,SAAS,CAAC,wBAAwB,CAAC,CAAC;QAC7F,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YACvB,OAAO,EAAE,EAAE,CAAC;YACZ,OAAO,GAAG,SAAS,CAAC;QACtB,CAAC;aAAM,CAAC;YACN,OAAO,KAAK,oBAAoB,CAAC,SAAS,CAAC,CAAC;QAC9C,CAAC;QACD,IAAI,GAAG,IAAI,CAAC;IACd,CAAC,CAAC;IACF,KAAK,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;IAC9B,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC1C,KAAK,CAAC,OAAO,GAAG,GAAG,EAAE;QACnB,SAAS,GAAG,IAAI,CAAC;QACjB,OAAO,EAAE,EAAE,CAAC;QACZ,OAAO,GAAG,SAAS,CAAC;QACpB,OAAO,EAAE,CAAC;IACZ,CAAC,CAAC;IACF,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,93 @@
1
+ import { type Easing } from './animate.ts';
2
+ import type { Transition } from './navigation-stack.ts';
3
+ import { type Platform } from './platform.ts';
4
+ export interface NativeTransitionOptions {
5
+ /**
6
+ * Whose push/pop to imitate. `auto` (the default) asks the browser and
7
+ * falls back to `ios`. It picks the defaults for everything below; an
8
+ * option given explicitly wins over the platform's, as a CSS variable wins
9
+ * over both.
10
+ */
11
+ platform: Platform | 'auto';
12
+ /** ms, programmatic push/pop */
13
+ duration: number;
14
+ /**
15
+ * the curve a programmatic push/pop runs on. CSS runs it, so it has to be
16
+ * one CSS can spell: everything `cubicBezier()`, `bezierPath()` and
17
+ * `parseEasing()` build carries a `css` property. A bare `(t) => number` of
18
+ * your own has none, so the pages would run `linear` while `progress`
19
+ * reported your curve; give it a `css` property, or write the whole
20
+ * transition yourself.
21
+ */
22
+ ease: Easing;
23
+ /** fraction of the width the upper page travels (1 = from off-screen; Android slides a short way and fades) */
24
+ travel: number;
25
+ /** fraction of the width the lower page travels */
26
+ parallax: number;
27
+ /** opacity of the upper page when fully closed (1 = no fade) */
28
+ fade: number;
29
+ dimColor: string;
30
+ /** lower-page overlay opacity at p = 1 (≈0.35 suits dark UIs) */
31
+ dimMax: number;
32
+ /** box-shadow on the incoming page */
33
+ shadow: string;
34
+ /** ms bounds for finishing an interactive pop */
35
+ settleMin: number;
36
+ settleMax: number;
37
+ /** the curve the remaining distance of an interactive pop runs on; see `ease` */
38
+ settleEase: Easing;
39
+ /** px/s assumed when the pointer was slower than this */
40
+ settleVelocityFloor: number;
41
+ /** multiplies every duration, for slow motion and tests */
42
+ timeScale: number;
43
+ }
44
+ /** Every option except the platform, which is decided once and has no CSS variable. */
45
+ export type NativeTransitionPreset = Readonly<Omit<NativeTransitionOptions, 'platform'>>;
46
+ /**
47
+ * Each platform's own push/pop, as its system animates it.
48
+ *
49
+ * - `ios`: UIKit's navigation push. The upper page slides the full width with
50
+ * a shadow on its leading edge, the lower page parallaxes 30% and dims.
51
+ * - `android`: the framework's activity open/close since Android 13
52
+ * (`activity_open_enter.xml` and friends): both pages slide 96 dp, about a
53
+ * quarter of a phone, over 450 ms on `fast_out_extra_slow_in`, and the
54
+ * upper page fades through the first part of it. No shadow, no dim.
55
+ */
56
+ export declare function nativeTransitionPreset(platform: Platform): NativeTransitionPreset;
57
+ /** The CSS custom property behind each option. */
58
+ export declare const NATIVE_TRANSITION_CSS_VARS: Readonly<Record<keyof NativeTransitionPreset, string>>;
59
+ export interface NativeTransition extends Transition {
60
+ /** The JS options: the platform's preset with the caller's merged in. `platform` is the one chosen. Mutable at runtime. */
61
+ readonly options: NativeTransitionOptions & {
62
+ platform: Platform;
63
+ };
64
+ /** The values currently in force: `options` with the CSS variables applied over them. */
65
+ readonly resolved: Readonly<NativeTransitionOptions & {
66
+ platform: Platform;
67
+ }>;
68
+ /**
69
+ * Re-reads the CSS variables, from `el` or from the container of the last
70
+ * transition. Called at the start of every transition. Call it directly
71
+ * after changing `options` or the variables mid-animation.
72
+ */
73
+ refresh(el?: Element | null): void;
74
+ }
75
+ /**
76
+ * The platform's navigation transition: the upper page slides in from the
77
+ * trailing edge while the lower page parallaxes toward the leading edge. On
78
+ * iOS the upper page travels the full width under a shadow and the lower page
79
+ * dims; on Android both travel a short way and the upper page fades. Every
80
+ * value is a function of one number, p.
81
+ *
82
+ * Every option is also a CSS custom property on the container (see
83
+ * `NATIVE_TRANSITION_CSS_VARS`), read when a transition starts. A variable
84
+ * that is set wins over the JS option, so a stylesheet can slow the animation
85
+ * down or restyle it per theme without the app rebuilding the transition.
86
+ *
87
+ * p is only ever written at the ends of a phase. The stack puts that phase's
88
+ * duration and curve in `--sn-t` / `--sn-e` and CSS interpolates between the
89
+ * two writes, so the animation costs a handful of style writes rather than one
90
+ * per page per frame, and runs on the compositor rather than the main thread.
91
+ */
92
+ export declare function createNativeTransition(options?: Partial<NativeTransitionOptions>): NativeTransition;
93
+ //# sourceMappingURL=native-transition.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"native-transition.d.ts","sourceRoot":"","sources":["../src/native-transition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiC,KAAK,MAAM,EAAE,MAAM,cAAc,CAAC;AAE1E,OAAO,KAAK,EAA2B,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACjF,OAAO,EAAkB,KAAK,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE9D,MAAM,WAAW,uBAAuB;IACtC;;;;;OAKG;IACH,QAAQ,EAAE,QAAQ,GAAG,MAAM,CAAC;IAC5B,gCAAgC;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;;;;OAOG;IACH,IAAI,EAAE,MAAM,CAAC;IACb,+GAA+G;IAC/G,MAAM,EAAE,MAAM,CAAC;IACf,mDAAmD;IACnD,QAAQ,EAAE,MAAM,CAAC;IACjB,gEAAgE;IAChE,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,iEAAiE;IACjE,MAAM,EAAE,MAAM,CAAC;IACf,sCAAsC;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,iDAAiD;IACjD,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,iFAAiF;IACjF,UAAU,EAAE,MAAM,CAAC;IACnB,yDAAyD;IACzD,mBAAmB,EAAE,MAAM,CAAC;IAC5B,2DAA2D;IAC3D,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,uFAAuF;AACvF,MAAM,MAAM,sBAAsB,GAAG,QAAQ,CAAC,IAAI,CAAC,uBAAuB,EAAE,UAAU,CAAC,CAAC,CAAC;AAEzF;;;;;;;;;GASG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,QAAQ,GAAG,sBAAsB,CAKjF;AAED,kDAAkD;AAClD,eAAO,MAAM,0BAA0B,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,sBAAsB,EAAE,MAAM,CAAC,CAc5F,CAAC;AAEH,MAAM,WAAW,gBAAiB,SAAQ,UAAU;IAClD,2HAA2H;IAC3H,QAAQ,CAAC,OAAO,EAAE,uBAAuB,GAAG;QAAE,QAAQ,EAAE,QAAQ,CAAA;KAAE,CAAC;IACnE,yFAAyF;IACzF,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,uBAAuB,GAAG;QAAE,QAAQ,EAAE,QAAQ,CAAA;KAAE,CAAC,CAAC;IAC9E;;;;OAIG;IACH,OAAO,CAAC,EAAE,CAAC,EAAE,OAAO,GAAG,IAAI,GAAG,IAAI,CAAC;CACpC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,GAAE,OAAO,CAAC,uBAAuB,CAAM,GAAG,gBAAgB,CAkGvG"}
@@ -1,10 +1,29 @@
1
1
  import { easings, prefersReducedMotion } from "./animate.js";
2
2
  import { cssVars, parseEasing, parseNumber, parseRatio, parseTime } from "./css-vars.js";
3
+ import { detectPlatform } from "./platform.js";
4
+ /**
5
+ * Each platform's own push/pop, as its system animates it.
6
+ *
7
+ * - `ios`: UIKit's navigation push. The upper page slides the full width with
8
+ * a shadow on its leading edge, the lower page parallaxes 30% and dims.
9
+ * - `android`: the framework's activity open/close since Android 13
10
+ * (`activity_open_enter.xml` and friends): both pages slide 96 dp, about a
11
+ * quarter of a phone, over 450 ms on `fast_out_extra_slow_in`, and the
12
+ * upper page fades through the first part of it. No shadow, no dim.
13
+ */
14
+ export function nativeTransitionPreset(platform) {
15
+ const shared = { settleMin: 120, settleMax: 400, settleVelocityFloor: 900, timeScale: 1, dimColor: '#000' };
16
+ return platform === 'android'
17
+ ? { ...shared, duration: 450, ease: easings.android, travel: 0.25, parallax: 0.25, fade: 0, dimMax: 0, shadow: 'none', settleEase: easings.androidSettle }
18
+ : { ...shared, duration: 500, ease: easings.ios, travel: 1, parallax: 0.3, fade: 1, dimMax: 0.1, shadow: '-3px 0 14px rgba(0,0,0,0.16)', settleEase: easings.easeOut };
19
+ }
3
20
  /** The CSS custom property behind each option. */
4
- export const IOS_TRANSITION_CSS_VARS = /*#__PURE__*/ Object.freeze({
21
+ export const NATIVE_TRANSITION_CSS_VARS = /*#__PURE__*/ Object.freeze({
5
22
  duration: '--sn-duration',
6
23
  ease: '--sn-easing',
24
+ travel: '--sn-travel',
7
25
  parallax: '--sn-parallax',
26
+ fade: '--sn-fade',
8
27
  dimColor: '--sn-dim-color',
9
28
  dimMax: '--sn-dim-max',
10
29
  shadow: '--sn-shadow',
@@ -15,46 +34,39 @@ export const IOS_TRANSITION_CSS_VARS = /*#__PURE__*/ Object.freeze({
15
34
  timeScale: '--sn-time-scale',
16
35
  });
17
36
  /**
18
- * The iOS navigation transition: the upper page slides in from the trailing
19
- * edge with a shadow on its leading edge, while the lower page parallaxes
20
- * toward the leading edge and dims. Every value is a function of one number, p.
37
+ * The platform's navigation transition: the upper page slides in from the
38
+ * trailing edge while the lower page parallaxes toward the leading edge. On
39
+ * iOS the upper page travels the full width under a shadow and the lower page
40
+ * dims; on Android both travel a short way and the upper page fades. Every
41
+ * value is a function of one number, p.
21
42
  *
22
43
  * Every option is also a CSS custom property on the container (see
23
- * `IOS_TRANSITION_CSS_VARS`), read when a transition starts. A variable that
24
- * is set wins over the JS option, so a stylesheet can slow the animation down
25
- * or restyle it per theme without the app rebuilding the transition.
44
+ * `NATIVE_TRANSITION_CSS_VARS`), read when a transition starts. A variable
45
+ * that is set wins over the JS option, so a stylesheet can slow the animation
46
+ * down or restyle it per theme without the app rebuilding the transition.
26
47
  *
27
48
  * p is only ever written at the ends of a phase. The stack puts that phase's
28
49
  * duration and curve in `--sn-t` / `--sn-e` and CSS interpolates between the
29
50
  * two writes, so the animation costs a handful of style writes rather than one
30
51
  * per page per frame, and runs on the compositor rather than the main thread.
31
52
  */
32
- export function createIOSTransition(options = {}) {
33
- const o = {
34
- duration: 500,
35
- ease: easings.ios,
36
- parallax: 0.3,
37
- dimColor: '#000',
38
- dimMax: 0.1,
39
- shadow: '-3px 0 14px rgba(0,0,0,0.16)',
40
- settleMin: 120,
41
- settleMax: 400,
42
- settleEase: easings.easeOut,
43
- settleVelocityFloor: 900,
44
- timeScale: 1,
45
- ...options,
46
- };
53
+ export function createNativeTransition(options = {}) {
54
+ const platform = !options.platform || options.platform === 'auto' ? detectPlatform() : options.platform;
55
+ const o = { ...nativeTransitionPreset(platform), ...options, platform };
47
56
  let root = null;
48
57
  let r = { ...o };
49
58
  const refresh = (el) => {
50
59
  if (el !== undefined)
51
60
  root = el;
52
61
  const read = cssVars(root);
53
- const v = IOS_TRANSITION_CSS_VARS;
62
+ const v = NATIVE_TRANSITION_CSS_VARS;
54
63
  r = {
64
+ platform: o.platform,
55
65
  duration: parseTime(read(v.duration)) ?? o.duration,
56
66
  ease: parseEasing(read(v.ease)) ?? o.ease,
67
+ travel: parseRatio(read(v.travel)) ?? o.travel,
57
68
  parallax: parseRatio(read(v.parallax)) ?? o.parallax,
69
+ fade: parseRatio(read(v.fade)) ?? o.fade,
58
70
  dimColor: read(v.dimColor) ?? o.dimColor,
59
71
  dimMax: parseRatio(read(v.dimMax)) ?? o.dimMax,
60
72
  shadow: read(v.shadow) ?? o.shadow,
@@ -117,7 +129,11 @@ export function createIOSTransition(options = {}) {
117
129
  * page, so a resize mid-transition stays honest.
118
130
  */
119
131
  apply(lower, upper, p) {
120
- upper.el.style.transform = shift(1 - p);
132
+ upper.el.style.transform = shift((1 - p) * r.travel);
133
+ // Only a look that fades writes opacity: a property that is not written
134
+ // starts no transition, and a page's own opacity is left alone.
135
+ if (r.fade < 1)
136
+ upper.el.style.opacity = String(round(r.fade + (1 - r.fade) * p));
121
137
  if (lower) {
122
138
  lower.el.style.transform = shift(-p * r.parallax);
123
139
  dim.style.opacity = String(p * r.dimMax);
@@ -126,10 +142,11 @@ export function createIOSTransition(options = {}) {
126
142
  end(lower, upper) {
127
143
  upper.el.style.boxShadow = '';
128
144
  upper.el.style.transform = '';
145
+ upper.el.style.opacity = '';
129
146
  if (lower)
130
147
  lower.el.style.transform = '';
131
148
  dim?.remove();
132
149
  },
133
150
  };
134
151
  }
135
- //# sourceMappingURL=ios-transition.js.map
152
+ //# sourceMappingURL=native-transition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"native-transition.js","sourceRoot":"","sources":["../src/native-transition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,oBAAoB,EAAe,MAAM,cAAc,CAAC;AAC1E,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAEzF,OAAO,EAAE,cAAc,EAAiB,MAAM,eAAe,CAAC;AA8C9D;;;;;;;;;GASG;AACH,MAAM,UAAU,sBAAsB,CAAC,QAAkB;IACvD,MAAM,MAAM,GAAG,EAAE,SAAS,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,EAAE,mBAAmB,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC,EAA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ACzC,GAAG,EAAE,MAAM,EAAE,CAAC;QAChB,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -112,6 +112,8 @@ export declare class NavigationStack {
112
112
  readonly pageClass: string;
113
113
  entries: StackEntry[];
114
114
  busy: boolean;
115
+ private _destroyed;
116
+ private _activeTransition;
115
117
  private _queue;
116
118
  private _listeners;
117
119
  constructor({ container, transition, pageClass }: NavigationStackOptions);
@@ -164,6 +166,7 @@ export declare class NavigationStack {
164
166
  }): Promise<StackEntry[]>;
165
167
  /** Starts a pointer-driven pop. Returns null if the stack cannot pop right now. */
166
168
  beginInteractivePop(): InteractivePopHandle | null;
169
+ /** Terminal: queued and subsequent navigation reject with AbortError. */
167
170
  destroy(): void;
168
171
  private _setBusy;
169
172
  /** Serializes operations: while a transition runs, later calls wait their turn. */
@@ -1 +1 @@
1
- {"version":3,"file":"navigation-stack.d.ts","sourceRoot":"","sources":["../src/navigation-stack.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0F,KAAK,MAAM,EAAE,MAAM,cAAc,CAAC;AAEnI,4FAA4F;AAC5F,MAAM,WAAW,UAAU,CAAC,CAAC,GAAG,OAAO;IACrC,EAAE,EAAE,WAAW,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,IAAI,EAAE,CAAC,GAAG,IAAI,CAAC;CAChB;AAED,MAAM,WAAW,WAAW;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,kFAAkF;IAClF,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,KAAK,EAAE,WAAW,GAAG;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IAC/D,KAAK,C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16
+ _activeTransition = null;
15
17
  _queue = [];
16
18
  _listeners = new Map();
17
19
  constructor({ container, transition, pageClass = 'sn-page' }) {
@@ -49,6 +51,8 @@ export class NavigationStack {
49
51
  };
50
52
  }
51
53
  _emit(event, detail) {
54
+ if (this._destroyed)
55
+ return;
52
56
  const set = this._listeners.get(event);
53
57
  if (set)
54
58
  set.forEach((fn) => fn(detail));
@@ -171,13 +175,19 @@ export class NavigationStack {
171
175
  this._begin(lower, upper, 'interactive');
172
176
  return {
173
177
  update: (v) => {
178
+ if (this._destroyed)
179
+ return;
174
180
  p = Math.min(1, Math.max(0, v));
175
181
  this._apply(lower, upper, p);
176
182
  },
177
183
  finish: async ({ complete, velocity = 0 }) => {
184
+ if (this._destroyed)
185
+ return;
178
186
  const remainingPx = (complete ? p : 1 - p) * this.width();
179
187
  const { duration, ease } = this.transition.settle({ remainingPx, velocity });
180
188
  await this._animate(lower, upper, p, complete ? 0 : 1, duration, ease);
189
+ if (this._destroyed)
190
+ return;
181
191
  this._end(lower, upper, 'interactive');
182
192
  if (complete) {
183
193
  this.entries.pop();
@@ -191,7 +201,23 @@ export class NavigationStack {
191
201
  },
192
202
  };
193
203
  }
204
+ /** Terminal: queued and subsequent navigation reject with AbortError. */
194
205
  destroy() {
206
+ if (this._destroyed)
207
+ return;
208
+ this._destroyed = true;
209
+ this._listeners.clear();
210
+ for (const task of this._queue.splice(0))
211
+ task.cancel();
212
+ this.busy = false;
213
+ const active = this._activeTransition;
214
+ this._activeTransition = null;
215
+ if (active) {
216
+ this.transition.end?.(active.lower, active.upper);
217
+ // During a pop the outgoing page has already left entries.
218
+ if (!this.entries.includes(active.upper))
219
+ this._unmount(active.upper);
220
+ }
195
221
  while (this.entries.length)
196
222
  this._unmount(this.entries.pop());
197
223
  this.container.classList.remove('sn-container', 'sn-busy');
@@ -200,12 +226,17 @@ export class NavigationStack {
200
226
  }
201
227
  // -------------------------------------------------------------- internals
202
228
  _setBusy(v) {
229
+ if (this._destroyed)
230
+ return;
203
231
  this.busy = v;
204
232
  this.container.classList.toggle('sn-busy', v);
205
233
  }
206
234
  /** Serializes operations: while a transition runs, later calls wait their turn. */
207
235
  _run(fn) {
208
236
  return new Promise((resolve, reject) => {
237
+ const cancel = () => reject(new DOMException('NavigationStack has been destroyed', 'AbortError'));
238
+ if (this._destroyed)
239
+ return cancel();
209
240
  const task = async () => {
210
241
  this._setBusy(true);
211
242
  try {
@@ -220,14 +251,14 @@ export class NavigationStack {
220
251
  }
221
252
  };
222
253
  if (this.busy)
223
- this._queue.push(task);
254
+ this._queue.push({ run: task, cancel });
224
255
  else
225
256
  task();
226
257
  });
227
258
  }
228
259
  _drain() {
229
- if (!this.busy && this._queue.length)
230
- this._queue.shift()();
260
+ if (!this._destroyed && !this.busy && this._queue.length)
261
+ this._queue.shift().run();
231
262
  }
232
263
  async _popRevealing(depth, animated, source) {
233
264
  const upper = this.entries.pop(); // the visible page: it animates out
@@ -236,6 +267,8 @@ export class NavigationStack {
236
267
  removed.push(this._unmount(this.entries.pop())); // intermediate pages: removed without animation
237
268
  const lower = this.top;
238
269
  await this._transition(lower, upper, 1, 0, animated, 'pop');
270
+ if (this._destroyed)
271
+ return upper;
239
272
  removed.push(this._unmount(upper));
240
273
  this._settle();
241
274
  this._emit('pop', { entry: upper, removed, entries: this.entries.slice(), source });
@@ -269,10 +302,13 @@ export class NavigationStack {
269
302
  * `prefers-reduced-motion` reduces every phase to.
270
303
  */
271
304
  _timing(duration, ease) {
305
+ if (this._destroyed)
306
+ return;
272
307
  this.container.style.setProperty('--sn-t', cssDuration(duration));
273
308
  this.container.style.setProperty('--sn-e', cssEasing(ease));
274
309
  }
275
310
  _begin(lower, upper, kind) {
311
+ this._activeTransition = { lower, upper };
276
312
  this._timing(0);
277
313
  lower?.el.classList.add('sn-page-visible', 'sn-page-lower');
278
314
  upper.el.classList.add('sn-page-visible', 'sn-page-upper');
@@ -284,6 +320,9 @@ export class NavigationStack {
284
320
  this._emit('progress', { lower, upper, p });
285
321
  }
286
322
  _end(lower, upper, kind) {
323
+ if (this._destroyed)
324
+ return;
325
+ this._activeTransition = null;
287
326
  this._timing(0);
288
327
  upper.el.classList.remove('sn-page-upper');
289
328
  lower?.el.classList.remove('sn-page-lower');