@stacknav/core 0.2.0 → 0.3.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 CHANGED
@@ -11,6 +11,9 @@ styling stay the app's own; the engine only moves them.
11
11
  - **Scroll and state are preserved.** Pages beneath the top stay mounted and
12
12
  hidden. Only `transform` is written, so scroll offsets, form state and focus
13
13
  survive.
14
+ - **CSS runs the animation.** The engine writes where the pages should end up
15
+ and hands the browser that phase's duration and curve; the frames in between
16
+ are the compositor's, not the main thread's.
14
17
  - **Direction resolution** for router-driven apps: composable strategies decide
15
18
  push / pop / replace.
16
19
  - **Browser back** for apps without a router, through an optional history
@@ -19,8 +22,8 @@ styling stay the app's own; the engine only moves them.
19
22
  - **Tunable from CSS.** Duration, curve, parallax, dim and shadow are custom
20
23
  properties on the container, so a media query or theme class can retune the
21
24
  animation without touching the app's JS.
22
- - **Custom chrome.** Subscribe to `progress` events and drive a fixed header or
23
- tab bar from the same `p`.
25
+ - **Custom chrome.** Move a header or a tab bar in step with the pages from CSS,
26
+ or subscribe to `progress` events and drive it from the same `p`.
24
27
  - No dependencies. Plain ES modules with type declarations.
25
28
 
26
29
  ## Use
@@ -45,6 +48,18 @@ The container needs a height; it becomes `position: relative; overflow: hidden`.
45
48
  Each page is an element you create. The stack gives it
46
49
  `position: absolute; inset: 0; overflow-y: auto` and manages its visibility.
47
50
 
51
+ ## How it moves
52
+
53
+ The engine does not animate anything. For each phase it writes two custom properties on the container — `--sn-t` and `--sn-e`, the duration and curve in force — and then writes where the pages should end up. CSS does the rest:
54
+
55
+ | Phase | `--sn-t` | What is written |
56
+ | --- | --- | --- |
57
+ | push / pop | the transition's `duration` | the far endpoint, once |
58
+ | a finger on the screen | `0s` | the current `p`, per pointer move |
59
+ | the release | `settle()`'s duration | the endpoint it is settling to, once |
60
+
61
+ So a 500 ms push costs about a dozen style writes in total rather than one per page per frame, the travel is a percentage of the page (no layout is ever measured), and `transform` and `opacity` stay on the compositor — a busy main thread no longer stutters the transition. `prefers-reduced-motion` is a media query in the stylesheet, so it wins even over a duration the engine wrote.
62
+
48
63
  ## API
49
64
 
50
65
  ### `createIOSStack({ container, transition?, gesture? })`
@@ -164,7 +179,13 @@ variable name.
164
179
  A transition is just
165
180
  `{ duration, ease, settle(), begin?(), apply(lower, upper, p), end?() }`, so you
166
181
  can write a different one (a fade, a vertical sheet) and pass it to
167
- `new NavigationStack({ container, transition })`. `cssVars()` and the
182
+ `new NavigationStack({ container, transition })`. `apply` is a declarative
183
+ write, not a frame: the stack calls it once at each end of a phase and lets CSS
184
+ interpolate between them, so keep it to `transform` and `opacity` and the
185
+ browser keeps it off the main thread. `ease` is sampled to report `progress`,
186
+ but its `css` property is what drives the pixels — `cubicBezier()` and
187
+ `parseEasing()` set one, and a bare `(t) => number` of your own does not, so
188
+ such a curve runs `linear` on screen unless you give it a `css` property too. `cssVars()` and the
168
189
  `parseTime` / `parseNumber` / `parseRatio` / `parseEasing` helpers are exported
169
190
  so a custom transition can read variables the same way. Each returns `undefined`
170
191
  rather than `NaN` for anything it cannot parse, so `?? yourDefault` is all the
@@ -184,6 +205,12 @@ handling a value needs.
184
205
 
185
206
  Call `gesture.refresh()` after changing options at runtime.
186
207
 
208
+ The leading edge is whichever edge the container reads from, so in a
209
+ right-to-left container the strip sits on the right and back is a drag to the
210
+ left. The recognizer and the transition both take that from `--sn-dir`, which
211
+ the stylesheet sets under `:dir(rtl)`, falling back to the container's computed
212
+ `direction`; set `--sn-dir: -1` yourself to flip both without an RTL document.
213
+
187
214
  ### `attachBrowserHistory(stack, { key = "snDepth", animateHistoryPop, onForward })`
188
215
 
189
216
  For apps without a router. Mirrors stack depth into `history.state`. Returns a
@@ -191,14 +218,29 @@ detach function. `animateHistoryPop` defaults to `false` on iOS browsers and
191
218
  `true` elsewhere. Forward navigation has no page to show, so by default it
192
219
  bounces back; pass `onForward(targetDepth)` to re-push something instead.
193
220
 
221
+ ### Your own chrome
222
+
223
+ A header or tab bar that should move with the pages can read the same state the engine gives CSS — `--sn-t` and `--sn-e` on the container, and the `sn-page-upper` / `sn-page-lower` classes on the two pages taking part — and it will run on the compositor alongside them:
224
+
225
+ ```css
226
+ .my-header { transition: opacity var(--sn-t) var(--sn-e); }
227
+ ```
228
+
229
+ For chrome that needs the number itself, `progress` still fires with `(lower, upper, p)`. It now costs a frame loop, so the engine only runs one while something is subscribed.
230
+
194
231
  ### Styles
195
232
 
196
- `injectStyles()` inserts the engine's four rules once. `STACKNAV_CSS` is the same
233
+ `injectStyles()` inserts the engine's rules once. `STACKNAV_CSS` is the same
197
234
  CSS as a string, minified because it rides along in your JS bundle, and
198
- `@stacknav/core/stacknav.css` is the same CSS as a readable file. It covers
199
- layout only and declares no custom properties: the tuning variables above are
200
- listed in a comment in the file rather than set, so that leaving one out means
201
- "use the default".
235
+ `@stacknav/core/stacknav.css` is the same CSS as a readable file.
236
+
237
+ It covers layout and the motion itself the `transition` rules the pages run
238
+ on — and declares none of the tuning variables above: they are listed in a
239
+ comment in the file rather than set, so that leaving one out means "use the
240
+ default". While a phase is in flight the engine writes two properties of its own
241
+ on the container, `--sn-t` and `--sn-e`, and marks the two pages taking part
242
+ `sn-page-upper` and `sn-page-lower`. Anything of yours that should move with
243
+ them can transition off the same four.
202
244
 
203
245
  ## Footprint
204
246
 
@@ -206,12 +248,12 @@ Plain ES modules, no dependencies, no work at module load: a bundler keeps only
206
248
 
207
249
  | You import | Costs |
208
250
  | --- | --- |
209
- | `createIOSStack` (stack, iOS look, swipe back) | ~4.1 kB |
210
- | `NavigationStack` with your own transition | ~2.0 kB |
251
+ | `createIOSStack` (stack, iOS look, swipe back) | ~4.5 kB |
252
+ | `NavigationStack` with your own transition | ~2.4 kB |
211
253
  | the direction strategies | ~0.6 kB |
212
- | `attachBrowserHistory` | ~0.4 kB |
213
- | `injectStyles` | ~0.3 kB |
214
- | everything | ~5.4 kB |
254
+ | `attachBrowserHistory` | ~0.5 kB |
255
+ | `injectStyles` | ~0.5 kB |
256
+ | everything | ~5.9 kB |
215
257
 
216
258
  ## Develop
217
259
 
@@ -223,13 +265,13 @@ pnpm size # what each entry point costs, minified + gzipped (after a bui
223
265
 
224
266
  ```
225
267
  src/
226
- animate.ts cubic-bezier solver, cancellable tween, easings
268
+ animate.ts curves CSS and JS can both read, the tween, the waits
227
269
  css-vars.ts reading and parsing the engine's custom properties
228
270
  navigation-stack.ts the stack: mounting, ordering, transition lifecycle, queueing
229
- ios-transition.ts the look: slide, parallax, dim, shadow, settle timing
271
+ ios-transition.ts the look: the endpoints, the settle timing, the variables
230
272
  edge-pan-gesture.ts pointer-event recognizer that drives the interactive pop
231
273
  direction.ts push / pop / replace strategies and the resolver
232
274
  history-adapter.ts history.state mirroring for apps without a router
233
- styles.ts the CSS the engine needs, and injectStyles()
275
+ styles.ts the CSS the engine needs, motion included, and injectStyles()
234
276
  index.ts exports + createIOSStack()
235
277
  ```
package/dist/animate.d.ts CHANGED
@@ -1,10 +1,23 @@
1
- export type Easing = (t: number) => number;
1
+ /**
2
+ * An easing curve. Callable, so the engine can sample it; `css` is the same
3
+ * curve spelled for `transition-timing-function`, which is what actually
4
+ * drives the pixels. A plain `(t) => number` is still a valid easing, it just
5
+ * falls back to `linear` on the CSS side.
6
+ */
7
+ export interface Easing {
8
+ (t: number): number;
9
+ readonly css?: string;
10
+ }
2
11
  export declare function cubicBezier(x1: number, y1: number, x2: number, y2: number): Easing;
3
12
  export declare const easings: {
4
13
  linear: Easing;
5
14
  ios: Easing;
6
15
  easeOut: Easing;
7
16
  };
17
+ /** How an easing should be spelled for CSS. A curve with no spelling runs linearly. */
18
+ export declare const cssEasing: (ease: Easing | undefined) => string;
19
+ /** How a duration should be spelled for CSS. */
20
+ export declare const cssDuration: (ms: number) => string;
8
21
  export interface TweenOptions {
9
22
  from: number;
10
23
  to: number;
@@ -20,7 +33,27 @@ export type CancellableTween = Promise<void> & {
20
33
  * every frame. Returns a promise that resolves when the tween is done;
21
34
  * `promise.cancel()` stops it early. A duration of 0 or less jumps straight
22
35
  * to `to`.
36
+ *
37
+ * The engine does not use this to move pages, CSS does that. It uses it to
38
+ * report `progress` to listeners, and only while someone is listening.
23
39
  */
24
40
  export declare function tween({ from, to, duration, ease, onUpdate }: TweenOptions): CancellableTween;
41
+ /**
42
+ * Commits the styles written so far, so the *next* write is seen as a change
43
+ * and starts a CSS transition from here instead of being collapsed into it.
44
+ * One forced layout per transition, in place of a frame of JavaScript per
45
+ * frame of animation.
46
+ */
47
+ export declare function commitStyles(el: HTMLElement): void;
48
+ /**
49
+ * Resolves once the CSS transitions of `properties` on these elements have
50
+ * finished. Nothing running resolves immediately: no transition started, a
51
+ * zero duration, `prefers-reduced-motion`, an element that is not being
52
+ * rendered. Interrupted animations reject, which counts as finished.
53
+ *
54
+ * Only the named properties are waited on, so an app is free to keep its own
55
+ * animation running on a page without stalling the stack.
56
+ */
57
+ export declare function animationsFinished(els: Array<HTMLElement | null | undefined>, properties?: readonly string[]): Promise<void>;
25
58
  export declare const prefersReducedMotion: () => boolean;
26
59
  //# sourceMappingURL=animate.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"animate.d.ts","sourceRoot":"","sources":["../src/animate.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;AAE3C,wBAAgB,WAAW,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAiBlF;AAKD,eAAO,MAAM,OAAO,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAInE,CAAC;AAEF,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,M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;AAED,MAAM,MAAM,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG;IAAE,MAAM,IAAI,IAAI,CAAA;CAAE,CAAC;AAElE;;;;;;;;GAQG;AACH,wBAAgB,KAAK,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,QAAQ,EAAE,IAAqB,EAAE,QAAQ,EAAE,EAAE,YAAY,GAAG,gBAAgB,CA2B7G;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,EAAE,EAAE,WAAW,GAAG,IAAI,CAElD;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,KAAK,CAAC,WAAW,GAAG,IAAI,GAAG,SAAS,CAAC,EAAE,UAAU,GAAE,SAAS,MAAM,EAA6B,GAAG,OAAO,CAAC,IAAI,CAAC,CAUtJ;AAED,eAAO,MAAM,oBAAoB,QAAO,OACoD,CAAC"}
package/dist/animate.js CHANGED
@@ -1,12 +1,15 @@
1
- // A small animation toolkit: a cubic-bezier solver, a cancellable tween, and
2
- // the easing curves the iOS transition uses.
1
+ // A small animation toolkit. The pages themselves are moved by CSS (see
2
+ // styles.ts), so what is here is the arithmetic CSS cannot do for the engine:
3
+ // a curve it can both hand to CSS and sample in JS, the spellings CSS wants,
4
+ // a cancellable tween used only to report progress, and the two helpers that
5
+ // hand a run over to the browser.
3
6
  export function cubicBezier(x1, y1, x2, y2) {
4
7
  const A = (a, b) => 1 - 3 * b + 3 * a;
5
8
  const B = (a, b) => 3 * b - 6 * a;
6
9
  const C = (a) => 3 * a;
7
10
  const calc = (t, a, b) => ((A(a, b) * t + B(a, b)) * t + C(a)) * t;
8
11
  const slope = (t, a, b) => 3 * A(a, b) * t * t + 2 * B(a, b) * t + C(a);
9
- return (x) => {
12
+ const f = (x) => {
10
13
  if (x <= 0)
11
14
  return 0;
12
15
  if (x >= 1)
@@ -20,20 +23,28 @@ export function cubicBezier(x1, y1, x2, y2) {
20
23
  }
21
24
  return calc(t, y1, y2);
22
25
  };
26
+ return Object.assign(f, { css: `cubic-bezier(${x1}, ${y1}, ${x2}, ${y2})` });
23
27
  }
24
28
  // `#__PURE__` marks the module-load calls as droppable, so a bundler that does
25
29
  // not honour the package's `sideEffects` flag can still leave this module out
26
30
  // when nothing here is imported.
27
31
  export const easings = {
28
- linear: (t) => t,
32
+ linear: /*#__PURE__*/ Object.assign((t) => t, { css: 'linear' }),
29
33
  ios: /*#__PURE__*/ cubicBezier(0.32, 0.72, 0, 1), // the common approximation of UIKit's navigation curve
30
34
  easeOut: /*#__PURE__*/ cubicBezier(0.2, 0.8, 0.2, 1),
31
35
  };
36
+ /** How an easing should be spelled for CSS. A curve with no spelling runs linearly. */
37
+ export const cssEasing = (ease) => ease?.css ?? 'linear';
38
+ /** How a duration should be spelled for CSS. */
39
+ export const cssDuration = (ms) => (ms > 0 ? `${ms}ms` : '0s');
32
40
  /**
33
41
  * Animates a number from `from` to `to` over `duration` ms, calling `onUpdate`
34
42
  * every frame. Returns a promise that resolves when the tween is done;
35
43
  * `promise.cancel()` stops it early. A duration of 0 or less jumps straight
36
44
  * to `to`.
45
+ *
46
+ * The engine does not use this to move pages, CSS does that. It uses it to
47
+ * report `progress` to listeners, and only while someone is listening.
37
48
  */
38
49
  export function tween({ from, to, duration, ease = easings.linear, onUpdate }) {
39
50
  let raf = 0;
@@ -65,5 +76,36 @@ export function tween({ from, to, duration, ease = easings.linear, onUpdate }) {
65
76
  };
66
77
  return promise;
67
78
  }
79
+ /**
80
+ * Commits the styles written so far, so the *next* write is seen as a change
81
+ * and starts a CSS transition from here instead of being collapsed into it.
82
+ * One forced layout per transition, in place of a frame of JavaScript per
83
+ * frame of animation.
84
+ */
85
+ export function commitStyles(el) {
86
+ void el.offsetWidth;
87
+ }
88
+ /**
89
+ * Resolves once the CSS transitions of `properties` on these elements have
90
+ * finished. Nothing running resolves immediately: no transition started, a
91
+ * zero duration, `prefers-reduced-motion`, an element that is not being
92
+ * rendered. Interrupted animations reject, which counts as finished.
93
+ *
94
+ * Only the named properties are waited on, so an app is free to keep its own
95
+ * animation running on a page without stalling the stack.
96
+ */
97
+ export function animationsFinished(els, properties = ['transform', 'opacity']) {
98
+ const running = [];
99
+ for (const el of els) {
100
+ if (typeof el?.getAnimations !== 'function')
101
+ continue;
102
+ for (const animation of el.getAnimations()) {
103
+ const property = animation.transitionProperty;
104
+ if (property && properties.includes(property))
105
+ running.push(animation.finished.catch(() => { }));
106
+ }
107
+ }
108
+ return running.length ? Promise.all(running).then(() => { }) : Promise.resolve();
109
+ }
68
110
  export const prefersReducedMotion = () => typeof matchMedia === 'function' && matchMedia('(prefers-reduced-motion: reduce)').matches;
69
111
  //# sourceMappingURL=animate.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"animate.js","sourceRoot":"","sources":["../src/animate.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,6CAA6C;AAI7C,MAAM,UAAU,WAAW,CAAC,EAAU,EAAE,EAAU,EAAE,EAAU,EAAE,EAAU;IACxE,MAAM,CAAC,GAAG,CAAC,CAAS,EAAE,CAAS,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACtD,MAAM,CAAC,GAAG,CAAC,CAAS,EAAE,CAAS,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAClD,MAAM,CAAC,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC;IAC/B,MAAM,IAAI,GAAG,CAAC,CAAS,EAAE,CAAS,EAAE,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IAC3F,MAAM,KAAK,GAAG,CAAC,CAAS,EAAE,CAAS,EA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AAC;IAC5B,CAAC,CAAC;IACF,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,EAAe;IAC1C,KAAK,EAAE,CAAC,WAAW,CAAC;AACtB,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,kBAAkB,CAAC,GAA0C,EAAE,aAAgC,CAAC,WAAW,EAAE,SAAS,CAAC;IACrI,MAAM,OAAO,GAA4B,EAAE,CAAC;IAC5C,KAAK,MAAM,EAAE,IAAI,GAAG,EAAE,CAAC;QACrB,IAAI,OAAO,EAAE,EAAE,aAAa,KAAK,UAAU;YAAE,SAAS;QACtD,KAAK,MAAM,SAAS,IAAI,EAAE,CAAC,aAAa,EAAE,EAAE,CAAC;YAC3C,MAAM,QAAQ,GAAI,SAA6C,CAAC,kBAAkB,CAAC;YACnF,IAAI,QAAQ,IAAI,UAAU,CAAC,QAAQ,CAAC,QAAQ,CAAC;gBAAE,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC,CAAC;QAClG,CAAC;IACH,CAAC;IACD,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;AAClF,CAAC;AAED,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAY,EAAE,CAChD,OAAO,UAAU,KAAK,UAAU,IAAI,UAAU,CAAC,kCAAkC,CAAC,CAAC,OAAO,CAAC"}
@@ -28,6 +28,9 @@ export interface EdgePanGesture {
28
28
  * interactive pop from it. Built on pointer events, so it handles both mouse
29
29
  * and touch. Vertical movement early in the gesture hands the touch back to
30
30
  * native scrolling.
31
+ *
32
+ * "Leading" is whichever edge the container reads from, so in a right-to-left
33
+ * container the strip sits on the right and back is a drag to the left.
31
34
  */
32
35
  export declare function createEdgePanGesture(options?: Partial<EdgePanGestureOptions>): EdgePanGesture;
33
36
  //# sourceMappingURL=edge-pan-gesture.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"edge-pan-gesture.d.ts","sourceRoot":"","sources":["../src/edge-pan-gesture.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAwB,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAEnF,MAAM,WAAW,qBAAqB;IACpC,2DAA2D;IAC3D,SAAS,EAAE,MAAM,CAAC;IAClB,mDAAmD;IACnD,QAAQ,EAAE,OAAO,CAAC;IAClB,uDAAuD;IACvD,SAAS,EAAE,MAAM,CAAC;IAClB,qEAAqE;IACrE,kBAAkB,EAAE,MAAM,CAAC;IAC3B,oEAAoE;IACpE,iBAAiB,EAAE,MAAM,CAAC;IAC1B,kFAAkF;IAClF,gBAAgB,EAAE,MAAM,CAAC;IACzB,oFAAoF;IACpF,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,OAAO,EAAE,qBAAqB,CAAC;IACxC,+EAA+E;IAC/E,OAAO,IAAI,IAAI,CAAC;IAChB,MAAM,CAAC,KAAK,EAAE,eAAe,GAAG,cAAc,CAAC;IAC/C,MAAM,IAAI,IAAI,CAAC;CAChB;AAYD;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,GAAE,OAAO,CAAC,qBAAqB,CAAM,GAAG,cAAc,CAqHjG"}
1
+ {"version":3,"file":"edge-pan-gesture.d.ts","sourceRoot":"","sources":["../src/edge-pan-gesture.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAwB,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAEnF,MAAM,WAAW,qBAAqB;IACpC,2DAA2D;IAC3D,SAAS,EAAE,MAAM,CAAC;IAClB,mDAAmD;IACnD,QAAQ,EAAE,OAAO,CAAC;IAClB,uDAAuD;IACvD,SAAS,EAAE,MAAM,CAAC;IAClB,qEAAqE;IACrE,kBAAkB,EAAE,MAAM,CAAC;IAC3B,oEAAoE;IACpE,iBAAiB,EAAE,MAAM,CAAC;IAC1B,kFAAkF;IAClF,gBAAgB,EAAE,MAAM,CAAC;IACzB,oFAAoF;IACpF,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,OAAO,EAAE,qBAAqB,CAAC;IACxC,+EAA+E;IAC/E,OAAO,IAAI,IAAI,CAAC;IAChB,MAAM,CAAC,KAAK,EAAE,eAAe,GAAG,cAAc,CAAC;IAC/C,MAAM,IAAI,IAAI,CAAC;CAChB;AAcD;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,GAAE,OAAO,CAAC,qBAAqB,CAAM,GAAG,cAAc,CA4IjG"}
@@ -3,6 +3,9 @@
3
3
  * interactive pop from it. Built on pointer events, so it handles both mouse
4
4
  * and touch. Vertical movement early in the gesture hands the touch back to
5
5
  * native scrolling.
6
+ *
7
+ * "Leading" is whichever edge the container reads from, so in a right-to-left
8
+ * container the strip sits on the right and back is a drag to the left.
6
9
  */
7
10
  export function createEdgePanGesture(options = {}) {
8
11
  const o = {
@@ -18,6 +21,21 @@ export function createEdgePanGesture(options = {}) {
18
21
  };
19
22
  let stack;
20
23
  let strip = null;
24
+ /**
25
+ * Which way forward is, read the same way the pages read it: `--sn-dir` when
26
+ * the stylesheet sets it, the container's reading direction otherwise. Taking
27
+ * it from one place is what keeps the drag and the transition from disagreeing
28
+ * about which edge is the back edge.
29
+ */
30
+ const direction = () => {
31
+ const style = typeof getComputedStyle === 'function' ? getComputedStyle(stack.container) : null;
32
+ const declared = Number(style?.getPropertyValue('--sn-dir'));
33
+ if (declared < 0)
34
+ return -1;
35
+ if (declared > 0)
36
+ return 1;
37
+ return style?.direction === 'rtl' ? -1 : 1;
38
+ };
21
39
  let drag = null;
22
40
  let suppressClick = false;
23
41
  let offs = [];
@@ -28,12 +46,14 @@ export function createEdgePanGesture(options = {}) {
28
46
  return;
29
47
  if (ev.currentTarget === stack.container && !o.anywhere)
30
48
  return;
31
- drag = { id: ev.pointerId, target: ev.currentTarget, x0: ev.clientX, y0: ev.clientY, handle: null, p: 1, samples: [[ev.clientX, performance.now()]] };
49
+ drag = { id: ev.pointerId, target: ev.currentTarget, x0: ev.clientX, y0: ev.clientY, dir: direction(), handle: null, p: 1, samples: [[ev.clientX, performance.now()]] };
32
50
  };
33
51
  const onMove = (ev) => {
34
52
  if (!drag || ev.pointerId !== drag.id)
35
53
  return;
36
- const dx = ev.clientX - drag.x0;
54
+ // Signed so that "forward along the drag" is always positive, whichever
55
+ // edge the container calls leading.
56
+ const dx = (ev.clientX - drag.x0) * drag.dir;
37
57
  const dy = ev.clientY - drag.y0;
38
58
  if (!drag.handle) {
39
59
  if (Math.abs(dy) > o.verticalCancelSlop && Math.abs(dy) > Math.abs(dx)) {
@@ -71,7 +91,7 @@ export function createEdgePanGesture(options = {}) {
71
91
  const s = d.samples;
72
92
  const [x1, t1] = s[0];
73
93
  const [x2, t2] = s[s.length - 1];
74
- const velocity = t2 > t1 ? ((x2 - x1) / (t2 - t1)) * 1000 : 0;
94
+ const velocity = (t2 > t1 ? ((x2 - x1) / (t2 - t1)) * 1000 : 0) * d.dir;
75
95
  const cancelled = ev.type === 'pointercancel';
76
96
  const complete = !cancelled && (velocity > o.completeVelocity || (d.p < 1 - o.completeThreshold && velocity > o.cancelVelocity));
77
97
  // The click that follows a drag release must not activate whatever is under the pointer.
@@ -90,11 +110,17 @@ export function createEdgePanGesture(options = {}) {
90
110
  const EVENTS = { pointerdown: onDown, pointermove: onMove, pointerup: onUp, pointercancel: onUp };
91
111
  const listen = (el) => Object.entries(EVENTS).forEach(([k, f]) => el.addEventListener(k, f));
92
112
  const unlisten = (el) => Object.entries(EVENTS).forEach(([k, f]) => el.removeEventListener(k, f));
113
+ /**
114
+ * Whether the strip is shown at all is a CSS question — the stylesheet hides
115
+ * it when there is nothing to go back to, or when the whole page is the
116
+ * target — so this only has to say what is true.
117
+ */
93
118
  const refresh = () => {
94
119
  if (!strip)
95
120
  return;
96
121
  strip.style.width = o.edgeWidth + 'px';
97
- strip.style.display = o.anywhere || stack.entries.length < 2 ? 'none' : '';
122
+ stack.container.classList.toggle('sn-anywhere', o.anywhere);
123
+ stack.container.classList.toggle('sn-can-pop', stack.entries.length > 1);
98
124
  };
99
125
  const gesture = {
100
126
  options: o,
@@ -102,8 +128,8 @@ export function createEdgePanGesture(options = {}) {
102
128
  attach(s) {
103
129
  stack = s;
104
130
  strip = document.createElement('div');
131
+ strip.className = 'sn-edge';
105
132
  strip.setAttribute('aria-hidden', 'true');
106
- Object.assign(strip.style, { position: 'absolute', left: '0', top: '0', bottom: '0', zIndex: '10', touchAction: 'none' });
107
133
  stack.container.append(strip);
108
134
  listen(strip);
109
135
  listen(stack.container);
@@ -119,6 +145,7 @@ export function createEdgePanGesture(options = {}) {
119
145
  unlisten(strip);
120
146
  unlisten(stack.container);
121
147
  stack.container.removeEventListener('click', onClick, true);
148
+ stack.container.classList.remove('sn-anywhere', 'sn-can-pop');
122
149
  strip.remove();
123
150
  strip = null;
124
151
  },
@@ -1 +1 @@
1
- {"version":3,"file":"edge-pan-gesture.js","sourceRoot":"","sources":["../src/edge-pan-gesture.ts"],"names":[],"mappings":"AAsCA;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAAC,UAA0C,EAAE;IAC/E,MAAM,CAAC,GAA0B;QAC/B,SAAS,EAAE,EAAE;QACb,QAAQ,EAAE,KAAK;QACf,SAAS,EAAE,CAAC;QACZ,kBAAkB,EAAE,EAAE;QACtB,iBAAiB,EAAE,GAAG;QACtB,gBAAgB,EAAE,GAAG;QACrB,cAAc,EAAE,CAAC,GAAG;QACpB,eAAe,EAAE,CAAC;QAClB,GAAG,OAAO;KACX,CAAC;IAEF,IAAI,KAA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C,CAAC,CAAC;YACvF,OAAO,EAAE,CAAC;YACV,OAAO,OAAO,CAAC;QACjB,CAAC;QACD,MAAM;YACJ,IAAI,CAAC,KAAK;gBAAE,OAAO;YACnB,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;YACzB,QAAQ,CAAC,KAAK,CAAC,CAAC;YAChB,QAAQ,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;YAC1B,KAAK,CAAC,SAAS,CAAC,mBAAmB,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;YAC5D,KAAK,CAAC,SAAS,CAAC,SAAS,CAAC,MAAM,CAAC,aAAa,EAAE,YAAY,CAAC,CAAC;YAC9D,KAAK,CAAC,MAAM,EAAE,CAAC;YACf,KAAK,GAAG,IAAI,CAAC;QACf,CAAC;KACF,CAAC;IACF,OAAO,OAAO,CAAC;AACjB,CAAC"}
package/dist/index.d.ts CHANGED
@@ -8,7 +8,7 @@ export { createEdgePanGesture } from './edge-pan-gesture.ts';
8
8
  export type { EdgePanGesture, EdgePanGestureOptions } from './edge-pan-gesture.ts';
9
9
  export { attachBrowserHistory, isIOSBrowser } from './history-adapter.ts';
10
10
  export type { BrowserHistoryOptions } from './history-adapter.ts';
11
- export { cubicBezier, easings, tween, prefersReducedMotion } from './animate.ts';
11
+ export { cubicBezier, easings, cssEasing, cssDuration, tween, commitStyles, animationsFinished, prefersReducedMotion } from './animate.ts';
12
12
  export type { Easing, TweenOptions, CancellableTween } from './animate.ts';
13
13
  export { resolveDirection, createDirectionResolver, defaultStrategies, fromHint, fromHistory, fromStack, fromLevel, fromTree, always, segmentsOf, } from './direction.ts';
14
14
  export type { Direction, DirectionOpinion, DirectionStrategy, DirectionResolver, NavigationContext, NavigationTrigger, RouteRef, LevelOptions, TreeOptions, } from './direction.ts';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"m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C,oBAAoB,CAAC,CAAC;IAC3C,OAAO,CAAC,EAAE,OAAO,CAAC,qBAAqB,CAAC,CAAC;CAC1C;AAED,MAAM,WAAW,QAAS,SAAQ,eAAe;IAC/C,UAAU,EAAE,aAAa,CAAC;IAC1B,OAAO,EAAE,cAAc,CAAC;CACzB;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,EAAE,SAAS,EAAE,UAAe,EAAE,OAAY,EAAE,EAAE,eAAe,GAAG,QAAQ,CAYtG"}
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ export { createIOSTransition, IOS_TRANSITION_CSS_VARS } from "./ios-transition.j
3
3
  export { cssVars, parseTime, parseNumber, parseRatio, parseEasing } from "./css-vars.js";
4
4
  export { createEdgePanGesture } from "./edge-pan-gesture.js";
5
5
  export { attachBrowserHistory, isIOSBrowser } from "./history-adapter.js";
6
- export { cubicBezier, easings, tween, prefersReducedMotion } from "./animate.js";
6
+ export { cubicBezier, easings, cssEasing, cssDuration, tween, commitStyles, animationsFinished, prefersReducedMotion } 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";
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,E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AK,CAAC,CAAC;IAChB,KAAK,CAAC,OAAO,GAAG,CAAC,CAAC;IAClB,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC1C,KAAK,CAAC,OAAO,GAAG,GAAG,EAAE;QACnB,CAAC,CAAC,MAAM,EAAE,CAAC;QACX,OAAO,EAAE,CAAC;IACZ,CAAC,CAAC;IACF,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -3,7 +3,13 @@ import type { Transition } from './navigation-stack.ts';
3
3
  export interface IOSTransitionOptions {
4
4
  /** ms, programmatic push/pop */
5
5
  duration: number;
6
- /** the curve a programmatic push/pop runs on */
6
+ /**
7
+ * the curve a programmatic push/pop runs on. CSS runs it, so it has to be
8
+ * one CSS can spell: everything `cubicBezier()` and `parseEasing()` build
9
+ * carries a `css` property. A bare `(t) => number` of your own has none, so
10
+ * the pages would run `linear` while `progress` reported your curve; give it
11
+ * a `css` property, or write the whole transition yourself.
12
+ */
7
13
  ease: Easing;
8
14
  /** fraction of the width the lower page travels */
9
15
  parallax: number;
@@ -15,7 +21,7 @@ export interface IOSTransitionOptions {
15
21
  /** ms bounds for finishing an interactive pop */
16
22
  settleMin: number;
17
23
  settleMax: number;
18
- /** the curve the remaining distance of an interactive pop runs on */
24
+ /** the curve the remaining distance of an interactive pop runs on; see `ease` */
19
25
  settleEase: Easing;
20
26
  /** px/s assumed when the pointer was slower than this */
21
27
  settleVelocityFloor: number;
@@ -45,6 +51,11 @@ export interface IOSTransition extends Transition {
45
51
  * `IOS_TRANSITION_CSS_VARS`), read when a transition starts. A variable that
46
52
  * is set wins over the JS option, so a stylesheet can slow the animation down
47
53
  * or restyle it per theme without the app rebuilding the transition.
54
+ *
55
+ * p is only ever written at the ends of a phase. The stack puts that phase's
56
+ * duration and curve in `--sn-t` / `--sn-e` and CSS interpolates between the
57
+ * two writes, so the animation costs a handful of style writes rather than one
58
+ * per page per frame, and runs on the compositor rather than the main thread.
48
59
  */
49
60
  export declare function createIOSTransition(options?: Partial<IOSTransitionOptions>): IOSTransition;
50
61
  //# sourceMappingURL=ios-transition.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ios-transition.d.ts","sourceRoot":"","sources":["../src/ios-transition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiC,KAAK,MAAM,EAAE,MAAM,cAAc,CAAC;AAE1E,OAAO,KAAK,EAA2B,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEjF,MAAM,WAAW,oBAAoB;IACnC,gCAAgC;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,gDAAgD;IAChD,IAAI,EAAE,MAAM,CAAC;IACb,mDAAmD;IACnD,QAAQ,EAAE,MAAM,CAAC;IACjB,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,qEAAqE;IACrE,UAAU,EAAE,MAAM,CAAC;IACnB,yDAAyD;IACzD,mBAAmB,EAAE,MAAM,CAAC;IAC5B,2DAA2D;IAC3D,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,kDAAkD;AAClD,eAAO,MAAM,uBAAuB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,oBAAoB,EAAE,MAAM,CAAC,CAYvF,CAAC;AAEH,MAAM,WAAW,aAAc,SAAQ,UAAU;IAC/C,oFAAoF;IACpF,QAAQ,CAAC,OAAO,EAAE,oBAAoB,CAAC;IACvC,yFAAyF;IACzF,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,oBAAoB,CAAC,CAAC;IAClD;;;;OAIG;IACH,OAAO,CAAC,EAAE,CAAC,EAAE,OAAO,GAAG,IAAI,GAAG,IAAI,CAAC;CACpC;AAKD;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CAAC,OAAO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G,aAAa,CAsG9F"}
@@ -14,7 +14,6 @@ export const IOS_TRANSITION_CSS_VARS = /*#__PURE__*/ Object.freeze({
14
14
  settleVelocityFloor: '--sn-settle-velocity-floor',
15
15
  timeScale: '--sn-time-scale',
16
16
  });
17
- const DIM = /*#__PURE__*/ Symbol('dim');
18
17
  /**
19
18
  * The iOS navigation transition: the upper page slides in from the trailing
20
19
  * edge with a shadow on its leading edge, while the lower page parallaxes
@@ -24,6 +23,11 @@ const DIM = /*#__PURE__*/ Symbol('dim');
24
23
  * `IOS_TRANSITION_CSS_VARS`), read when a transition starts. A variable that
25
24
  * is set wins over the JS option, so a stylesheet can slow the animation down
26
25
  * or restyle it per theme without the app rebuilding the transition.
26
+ *
27
+ * p is only ever written at the ends of a phase. The stack puts that phase's
28
+ * duration and curve in `--sn-t` / `--sn-e` and CSS interpolates between the
29
+ * two writes, so the animation costs a handful of style writes rather than one
30
+ * per page per frame, and runs on the compositor rather than the main thread.
27
31
  */
28
32
  export function createIOSTransition(options = {}) {
29
33
  const o = {
@@ -61,19 +65,24 @@ export function createIOSTransition(options = {}) {
61
65
  timeScale: parseNumber(read(v.timeScale)) ?? o.timeScale,
62
66
  };
63
67
  };
64
- const dimOf = (entry) => {
65
- let d = entry[DIM];
66
- if (!d) {
67
- d = document.createElement('div');
68
- d.setAttribute('aria-hidden', 'true');
69
- Object.assign(d.style, { position: 'fixed', inset: '0', pointerEvents: 'none', opacity: '0', zIndex: '2147483647' });
70
- entry[DIM] = d;
68
+ // One overlay, moved to whichever page is underneath. Everything about it
69
+ // except its colour and its opacity is a rule in the stylesheet.
70
+ let dim = null;
71
+ const dimOf = (lower) => {
72
+ if (!dim) {
73
+ dim = document.createElement('div');
74
+ dim.className = 'sn-dim';
75
+ dim.setAttribute('aria-hidden', 'true');
71
76
  }
72
- d.style.background = r.dimColor;
73
- if (d.parentElement !== entry.el)
74
- entry.el.append(d);
75
- return d;
77
+ dim.style.background = r.dimColor;
78
+ if (dim.parentElement !== lower.el)
79
+ lower.el.append(dim);
80
+ return dim;
76
81
  };
82
+ /** Four decimals is well past a subpixel, and keeps the style strings short. */
83
+ const round = (n) => Math.round(n * 1e4) / 1e4 || 0;
84
+ /** A share of the page's own width, signed by the stylesheet's reading direction. */
85
+ const shift = (fraction) => `translate3d(calc(${round(fraction * 100)}% * var(--sn-dir,1)),0,0)`;
77
86
  return {
78
87
  options: o,
79
88
  get resolved() {
@@ -99,23 +108,25 @@ export function createIOSTransition(options = {}) {
99
108
  if (lower)
100
109
  dimOf(lower);
101
110
  },
111
+ /**
112
+ * The state at p, written declaratively. Two calls with `--sn-t` set to a
113
+ * duration make an animation; a call per pointer move with `--sn-t: 0s`
114
+ * makes a drag. Nothing here measures layout: the travel is a share of the
115
+ * page, so a resize mid-transition stays honest.
116
+ */
102
117
  apply(lower, upper, p) {
103
- const w = upper.el.parentElement?.clientWidth ?? 0;
104
- upper.el.style.transform = `translate3d(${(1 - p) * w}px,0,0)`;
118
+ upper.el.style.transform = shift(1 - p);
105
119
  if (lower) {
106
- lower.el.style.transform = `translate3d(${-p * r.parallax * w}px,0,0)`;
120
+ lower.el.style.transform = shift(-p * r.parallax);
107
121
  dimOf(lower).style.opacity = String(p * r.dimMax);
108
122
  }
109
123
  },
110
124
  end(lower, upper) {
111
125
  upper.el.style.boxShadow = '';
112
126
  upper.el.style.transform = '';
113
- if (lower) {
127
+ if (lower)
114
128
  lower.el.style.transform = '';
115
- const d = lower[DIM];
116
- if (d)
117
- d.remove();
118
- }
129
+ dim?.remove();
119
130
  },
120
131
  };
121
132
  }