@astryxdesign/core 0.7.7-canary.36f8ea1 → 0.7.7-canary.550ff21

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 (67) hide show
  1. package/dist/CommandPalette/CommandPaletteInput.d.ts.map +1 -1
  2. package/dist/CommandPalette/CommandPaletteInput.js +8 -1
  3. package/dist/DateInput/MonthScroller.d.ts.map +1 -1
  4. package/dist/DateInput/MonthScroller.js +72 -2
  5. package/dist/Field/PanelSearchInput.d.ts.map +1 -1
  6. package/dist/Field/PanelSearchInput.js +8 -1
  7. package/dist/Field/textEntryTraits.d.ts +6 -6
  8. package/dist/Field/textEntryTraits.js +6 -6
  9. package/dist/ProgressBar/ProgressBar.d.ts.map +1 -1
  10. package/dist/ProgressBar/ProgressBar.js +20 -9
  11. package/dist/ProgressBar/ProgressBarTouch.d.ts +29 -0
  12. package/dist/ProgressBar/ProgressBarTouch.d.ts.map +1 -0
  13. package/dist/ProgressBar/ProgressBarTouch.js +91 -0
  14. package/dist/Typeahead/BaseTypeahead.d.ts.map +1 -1
  15. package/dist/Typeahead/BaseTypeahead.js +9 -1
  16. package/dist/astryx.css +7 -0
  17. package/dist/gestures/GestureArena.d.ts +21 -2
  18. package/dist/gestures/GestureArena.d.ts.map +1 -1
  19. package/dist/gestures/GestureArena.js +19 -2
  20. package/dist/gestures/GestureHost.d.ts +51 -1
  21. package/dist/gestures/GestureHost.d.ts.map +1 -1
  22. package/dist/gestures/GestureHost.js +148 -7
  23. package/dist/motion/animator.d.ts.map +1 -1
  24. package/dist/motion/animator.js +63 -5
  25. package/dist/motion/paging.d.ts +58 -0
  26. package/dist/motion/paging.d.ts.map +1 -0
  27. package/dist/motion/paging.js +128 -0
  28. package/dist/motion/uikit/index.d.ts +4 -3
  29. package/dist/motion/uikit/index.d.ts.map +1 -1
  30. package/dist/motion/uikit/index.js +4 -3
  31. package/dist/motion/uikit/paging.d.ts +160 -0
  32. package/dist/motion/uikit/paging.d.ts.map +1 -0
  33. package/dist/motion/uikit/paging.js +162 -0
  34. package/dist/motion/uikit/progressBar.d.ts +59 -0
  35. package/dist/motion/uikit/progressBar.d.ts.map +1 -0
  36. package/dist/motion/uikit/progressBar.js +82 -0
  37. package/dist/motion/uikit/scroll.d.ts +0 -19
  38. package/dist/motion/uikit/scroll.d.ts.map +1 -1
  39. package/dist/motion/uikit/scroll.js +2 -21
  40. package/dist/utils/selectionLock.d.ts +43 -0
  41. package/dist/utils/selectionLock.d.ts.map +1 -1
  42. package/dist/utils/selectionLock.js +394 -6
  43. package/package.json +4 -4
  44. package/src/CommandPalette/CommandPaletteInput.tsx +6 -0
  45. package/src/DateInput/MonthScroller.tsx +63 -5
  46. package/src/Field/PanelSearchInput.tsx +6 -0
  47. package/src/Field/textEntryTraits.ts +6 -6
  48. package/src/ProgressBar/ProgressBar.doc.mjs +3 -3
  49. package/src/ProgressBar/ProgressBar.tsx +82 -11
  50. package/src/ProgressBar/ProgressBarTouch.ts +109 -0
  51. package/src/Typeahead/BaseTypeahead.tsx +7 -0
  52. package/src/gestures/GestureArena.ts +44 -4
  53. package/src/gestures/GestureHost.ts +184 -7
  54. package/src/gestures/README.md +19 -3
  55. package/src/motion/MEASUREMENTS.md +8 -1
  56. package/src/motion/README.md +6 -3
  57. package/src/motion/animator.ts +78 -6
  58. package/src/motion/paging.ts +138 -0
  59. package/src/motion/uikit/index.ts +4 -3
  60. package/src/motion/uikit/paging.ts +162 -0
  61. package/src/motion/uikit/progressBar.ts +82 -0
  62. package/src/motion/uikit/scroll.ts +2 -18
  63. package/src/utils/selectionLock.ts +501 -6
  64. package/dist/motion/selectPage.d.ts +0 -26
  65. package/dist/motion/selectPage.d.ts.map +0 -1
  66. package/dist/motion/selectPage.js +0 -55
  67. package/src/motion/selectPage.ts +0 -55
@@ -471,7 +471,7 @@ export class GestureArena {
471
471
  // --- Resolution ------------------------------------------------------------
472
472
 
473
473
  attemptRecognition(recognizer, next) {
474
- if (!internals(recognizer).shouldBegin() || this.isVetoedByConsumer(recognizer)) {
474
+ if (!internals(recognizer).shouldBegin() || this.isVetoedByConsumer(recognizer) || this.isRefusedByBrowser(recognizer)) {
475
475
  this.fail(recognizer);
476
476
  return;
477
477
  }
@@ -535,6 +535,18 @@ export class GestureArena {
535
535
  return winner.canPrevent(other) && other.canBePrevented(winner);
536
536
  }
537
537
 
538
+ /**
539
+ * Whether a recognizer that claims touches would take a contact the
540
+ * browser keeps while it is down (`refusesClaim`).
541
+ */
542
+ isRefusedByBrowser(recognizer) {
543
+ const refuses = this.options.refusesClaim;
544
+ if (refuses == null || !recognizer.claimsTouches) {
545
+ return false;
546
+ }
547
+ return recognizer.trackedTouches.some(touch => touch.phase !== 'ended' && touch.phase !== 'cancelled' && refuses(touch));
548
+ }
549
+
538
550
  /** UIControl's rule: a control may veto an overlapping ancestor recognizer. */
539
551
  isVetoedByConsumer(recognizer) {
540
552
  for (const id of internals(recognizer).seenTouchIds) {
@@ -570,6 +582,7 @@ export class GestureArena {
570
582
  * takes a touch another recognizer had.
571
583
  */
572
584
  releaseClaim(recognizer, keep = new Set()) {
585
+ const released = [];
573
586
  for (const touch of recognizer.trackedTouches) {
574
587
  const record = this.records.get(touch.id);
575
588
  if (record == null || !record.isClaimed || keep.has(touch.id)) {
@@ -580,8 +593,12 @@ export class GestureArena {
580
593
  const isOwned = this.active.some(other => other !== recognizer && other.claimsTouches && (isActive(other.state) || other.state === 'ended' || internals(other).pending != null) && other.trackedTouches.some(tracked => tracked.id === touch.id));
581
594
  if (!isOwned) {
582
595
  record.isClaimed = false;
596
+ released.push(touch.id);
583
597
  }
584
598
  }
599
+ if (released.length > 0) {
600
+ this.options.onRelease?.(released);
601
+ }
585
602
  }
586
603
  apply(recognizer, next) {
587
604
  const from = recognizer.state;
@@ -643,7 +660,7 @@ export class GestureArena {
643
660
  }
644
661
  }
645
662
  if (claimed.length > 0) {
646
- this.options.onClaim?.(claimed);
663
+ this.options.onClaim?.(claimed, recognizer);
647
664
  }
648
665
  }
649
666
 
@@ -65,6 +65,23 @@ export declare class GestureHost {
65
65
  private cancelCallerRead;
66
66
  /** The selection lock each contact holds, by host contact id. */
67
67
  private readonly lockedBy;
68
+ /**
69
+ * The page's selection when each mouse or pen press began: a drag a
70
+ * recognizer claims keeps it.
71
+ */
72
+ private readonly pressSelections;
73
+ /**
74
+ * Mouse and pen contacts that began on selectable text. Once one moves, the
75
+ * browser keeps the drag for a selection, and no recognizer claims it.
76
+ */
77
+ private readonly selectingContacts;
78
+ /**
79
+ * Drag selection holds until their last task ends, a task after their lift
80
+ * (lockDragSelection); the last detach ends them at once.
81
+ */
82
+ private readonly dragHolds;
83
+ /** Each claimed contact's drag hold, until its lift or a give-back. */
84
+ private readonly claimHolds;
68
85
  private readonly presentedHitTesting;
69
86
  /**
70
87
  * Contacts sent to what is drawn instead of what the engine hit, by host
@@ -477,6 +494,28 @@ export declare class GestureHost {
477
494
  * is subscribed.
478
495
  */
479
496
  private latchWheel;
497
+ /**
498
+ * Hold the page's selection for a mouse or pen contact that a recognizer
499
+ * claims. Examples are a pan's drag and a press a group claims at its own
500
+ * pointerdown. While the contact is down, the claiming recognizers'
501
+ * elements refuse a new selection. The selection the page had at the press
502
+ * is put back over anything that replaced it. That includes the press's own
503
+ * collapse and a selection the drag made before its claim. The claiming
504
+ * recognizer's element holds from its claim, in any state: a waiting
505
+ * recognizer claims while possible, and a swipe claims as ended. The
506
+ * participants that already recognize hold too. A claim given back to the
507
+ * browser lets its hold go (releaseClaimedDrags). A drag that starts on
508
+ * selectable text never gets here, because no recognizer claims it
509
+ * (`selectingContacts`). A tap claims only at its lift, so a click keeps
510
+ * the selection it made. A finger keeps the touch-down lock alone.
511
+ */
512
+ private lockClaimedDrags;
513
+ /**
514
+ * Claimed contacts the arena gave back. Their drag holds end at once, so
515
+ * the browser's drag selects again. A contact's press lock (lockSelection)
516
+ * is not a drag hold and stays.
517
+ */
518
+ private releaseClaimedDrags;
480
519
  /**
481
520
  * End the trackpad pan a recognizer still drives, when the page loses focus
482
521
  * or hides, and return its contacts to cancel. The rest of its stream is
@@ -495,7 +534,18 @@ export declare class GestureHost {
495
534
  * not share it.
496
535
  */
497
536
  private endWheel;
498
- /** Undo `lockSelection` for a contact that ended; idempotent. */
537
+ /**
538
+ * At a mouse or pen press, mark one that lands on selectable text: once it
539
+ * moves, it is the browser's drag, and selects text.
540
+ * Text whose hold does something is locked at this press already
541
+ * (lockSelection), so it is not selectable text.
542
+ */
543
+ private noteSelectingPress;
544
+ /**
545
+ * Undo a contact's selection locks, its press lock and its drag hold, at
546
+ * once for a cancel, and forget its press's selection; idempotent. A
547
+ * drag's hold keeps its last task after a lift (lockDragSelection).
548
+ */
499
549
  private unlockSelection;
500
550
  /**
501
551
  * Hold touches away from every participant while `gate(target)` answers
@@ -1 +1 @@
1
- {"version":3,"file":"GestureHost.d.ts","sourceRoot":"","sources":["../../src/gestures/GestureHost.ts"],"names":[],"mappings":"AAmIA,OAAO,EAEL,YAAY,EAGZ,KAAK,mBAAmB,EACxB,KAAK,YAAY,EAClB,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAC,iBAAiB,EAAgB,MAAM,qBAAqB,CAAC;AAC1E,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAqBhD,OAAO,KAAK,EAEV,YAAY,EAIZ,aAAa,EAGd,MAAM,SAAS,CAAC;AA0CjB,MAAM,WAAW,kBAAkB;IACjC,kDAAkD;IAClD,KAAK,CAAC,EAAE,YAAY,CAAC;IACrB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,gBAAgB,CAAC;IACtC,4DAA4D;IAC5D,YAAY,CAAC,EAAE,mBAAmB,CAAC,cAAc,CAAC,CAAC;IACnD;;;;;OAKG;IACH,mBAAmB,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC;IAClD;;;;;;;OAOG;IACH,sBAAsB,CAAC,EAAE,MAAM,OAAO,CAAC;CACxC;AAED,MAAM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QrC,+DAA+D;IAC/D,OAAO,CAAC,gBAAgB;CA0BzB;AAyBD,4DAA4D;AAC5D,wBAAgB,cAAc,CAAC,GAAG,EAAE,QAAQ,GAAG,WAAW,CAOzD"}
@@ -135,7 +135,7 @@ import { internals } from "./recognizerInternals.js";
135
135
  import { armClickGuard, disarmClickGuard, withoutClickGuard } from "../utils/clickGuard.js";
136
136
  import { subscribeInput } from "../utils/inputStream.js";
137
137
  import { isPrimaryClick } from "../utils/primaryClick.js";
138
- import { locksSelectionFor } from "../utils/selectionLock.js";
138
+ import { lockDragSelection, locksSelectionFor, selectionRangesOf, startsOnSelectableText } from "../utils/selectionLock.js";
139
139
  import { isCoarsePointer, watchCoarsePointer } from "../utils/coarsePointer.js";
140
140
  import { gestureHosts } from "./hostRegistry.js";
141
141
  const STYLE_PROPERTIES = {
@@ -404,6 +404,23 @@ export class GestureHost {
404
404
  cancelCallerRead = null;
405
405
  /** The selection lock each contact holds, by host contact id. */
406
406
  lockedBy = new Map();
407
+ /**
408
+ * The page's selection when each mouse or pen press began: a drag a
409
+ * recognizer claims keeps it.
410
+ */
411
+ pressSelections = new Map();
412
+ /**
413
+ * Mouse and pen contacts that began on selectable text. Once one moves, the
414
+ * browser keeps the drag for a selection, and no recognizer claims it.
415
+ */
416
+ selectingContacts = new Set();
417
+ /**
418
+ * Drag selection holds until their last task ends, a task after their lift
419
+ * (lockDragSelection); the last detach ends them at once.
420
+ */
421
+ dragHolds = new Set();
422
+ /** Each claimed contact's drag hold, until its lift or a give-back. */
423
+ claimHolds = new Map();
407
424
  /**
408
425
  * Contacts sent to what is drawn instead of what the engine hit, by host
409
426
  * contact id, with where they landed (for their click).
@@ -581,7 +598,10 @@ export class GestureHost {
581
598
  // A press whose decision waited on a timer (a tap waiting on a double
582
599
  // tap) ends here: an armed press stops listening (FR24).
583
600
  onIdle: () => this.releaseArmedPress(),
584
- onTransition: options.onTransition
601
+ onTransition: options.onTransition,
602
+ onClaim: (ids, claimer) => this.lockClaimedDrags(ids, claimer),
603
+ onRelease: ids => this.releaseClaimedDrags(ids),
604
+ refusesClaim: touch => this.selectingContacts.has(touch.id) && (touch.x !== touch.startX || touch.y !== touch.startY)
585
605
  });
586
606
  const view = doc.defaultView;
587
607
  // A test may pass its own read; otherwise the one coarse-pointer gate,
@@ -1422,6 +1442,15 @@ export class GestureHost {
1422
1442
  }
1423
1443
  this.ownScrollFrames.clear();
1424
1444
  this.ownedScrolls.clear();
1445
+ // A drag's hold whose press lifted in this task ends now, not a task
1446
+ // later: nothing is attached to meet its mouseup or click.
1447
+ for (const release of [...this.dragHolds]) {
1448
+ release({
1449
+ isCancel: true
1450
+ });
1451
+ }
1452
+ this.pressSelections.clear();
1453
+ this.selectingContacts.clear();
1425
1454
  });
1426
1455
  }
1427
1456
 
@@ -2051,6 +2080,79 @@ export class GestureHost {
2051
2080
  }
2052
2081
  }
2053
2082
 
2083
+ /**
2084
+ * Hold the page's selection for a mouse or pen contact that a recognizer
2085
+ * claims. Examples are a pan's drag and a press a group claims at its own
2086
+ * pointerdown. While the contact is down, the claiming recognizers'
2087
+ * elements refuse a new selection. The selection the page had at the press
2088
+ * is put back over anything that replaced it. That includes the press's own
2089
+ * collapse and a selection the drag made before its claim. The claiming
2090
+ * recognizer's element holds from its claim, in any state: a waiting
2091
+ * recognizer claims while possible, and a swipe claims as ended. The
2092
+ * participants that already recognize hold too. A claim given back to the
2093
+ * browser lets its hold go (releaseClaimedDrags). A drag that starts on
2094
+ * selectable text never gets here, because no recognizer claims it
2095
+ * (`selectingContacts`). A tap claims only at its lift, so a click keeps
2096
+ * the selection it made. A finger keeps the touch-down lock alone.
2097
+ */
2098
+ lockClaimedDrags(ids, claimer) {
2099
+ for (const id of ids) {
2100
+ if (this.claimHolds.has(id)) {
2101
+ continue;
2102
+ }
2103
+ const touch = this.arena.touches.find(each => each.id === id);
2104
+ // A claim made at the contact's own lift (a tap's) holds nothing: the
2105
+ // drag is over, and a click keeps the selection it made. A wheel's
2106
+ // contact keeps the page's selection, as a scroll does.
2107
+ if (touch == null || touch.pointerType === 'touch' || touch.scrollType != null || touch.phase === 'ended' || touch.phase === 'cancelled') {
2108
+ continue;
2109
+ }
2110
+ const elements = new Set();
2111
+ for (const recognizer of this.arena.participantsOf(id)) {
2112
+ if ((recognizer.state === 'began' || recognizer.state === 'changed') && recognizer.view?.nodeType === 1) {
2113
+ elements.add(recognizer.view);
2114
+ }
2115
+ }
2116
+ if (claimer.view?.nodeType === 1) {
2117
+ elements.add(claimer.view);
2118
+ }
2119
+ if (elements.size === 0) {
2120
+ continue;
2121
+ }
2122
+ const release = lockDragSelection(elements, this.doc.defaultView, this.pressSelections.get(id) ?? [], () => {
2123
+ this.dragHolds.delete(release);
2124
+ });
2125
+ this.dragHolds.add(release);
2126
+ // A press lock the contact took at its press stays in `lockedBy`. The
2127
+ // hold sits beside it, and the contact's end releases both.
2128
+ if (!this.lockedBy.has(id)) {
2129
+ this.lockedBy.set(id, release);
2130
+ }
2131
+ this.claimHolds.set(id, release);
2132
+ }
2133
+ }
2134
+
2135
+ /**
2136
+ * Claimed contacts the arena gave back. Their drag holds end at once, so
2137
+ * the browser's drag selects again. A contact's press lock (lockSelection)
2138
+ * is not a drag hold and stays.
2139
+ */
2140
+ releaseClaimedDrags(ids) {
2141
+ for (const id of ids) {
2142
+ const release = this.claimHolds.get(id);
2143
+ if (release == null) {
2144
+ continue;
2145
+ }
2146
+ this.claimHolds.delete(id);
2147
+ if (this.lockedBy.get(id) === release) {
2148
+ this.lockedBy.delete(id);
2149
+ }
2150
+ release({
2151
+ isCancel: true
2152
+ });
2153
+ }
2154
+ }
2155
+
2054
2156
  /**
2055
2157
  * End the trackpad pan a recognizer still drives, when the page loses focus
2056
2158
  * or hides, and return its contacts to cancel. The rest of its stream is
@@ -2132,10 +2234,40 @@ export class GestureHost {
2132
2234
  }] : this.pinchContacts(gesture, time));
2133
2235
  }
2134
2236
 
2135
- /** Undo `lockSelection` for a contact that ended; idempotent. */
2136
- unlockSelection(id) {
2137
- this.lockedBy.get(id)?.();
2237
+ /**
2238
+ * At a mouse or pen press, mark one that lands on selectable text: once it
2239
+ * moves, it is the browser's drag, and selects text.
2240
+ * Text whose hold does something is locked at this press already
2241
+ * (lockSelection), so it is not selectable text.
2242
+ */
2243
+ noteSelectingPress(id, x, y, target) {
2244
+ if (!this.lockedBy.has(id) && startsOnSelectableText(this.doc, x, y, target)) {
2245
+ this.selectingContacts.add(id);
2246
+ }
2247
+ }
2248
+
2249
+ /**
2250
+ * Undo a contact's selection locks, its press lock and its drag hold, at
2251
+ * once for a cancel, and forget its press's selection; idempotent. A
2252
+ * drag's hold keeps its last task after a lift (lockDragSelection).
2253
+ */
2254
+ unlockSelection(id, isCancel = false) {
2255
+ const lock = this.lockedBy.get(id);
2256
+ lock?.({
2257
+ isCancel
2258
+ });
2259
+ // A press lock keeps `lockedBy` when the contact also has a drag hold.
2260
+ // Release the hold too.
2261
+ const hold = this.claimHolds.get(id);
2262
+ if (hold != null && hold !== lock) {
2263
+ hold({
2264
+ isCancel
2265
+ });
2266
+ }
2138
2267
  this.lockedBy.delete(id);
2268
+ this.claimHolds.delete(id);
2269
+ this.pressSelections.delete(id);
2270
+ this.selectingContacts.delete(id);
2139
2271
  }
2140
2272
 
2141
2273
  // --- Touch events ----------------------------------------------------------
@@ -2830,6 +2962,11 @@ export class GestureHost {
2830
2962
  target
2831
2963
  });
2832
2964
  }
2965
+ // Before the arena admits it: a press a group claims at its own
2966
+ // pointerdown keeps the selection the page has now.
2967
+ if (event.pointerType !== 'touch') {
2968
+ this.pressSelections.set(id, selectionRangesOf(this.doc.defaultView));
2969
+ }
2833
2970
  this.arena.began([{
2834
2971
  id,
2835
2972
  x: event.clientX,
@@ -2846,6 +2983,10 @@ export class GestureHost {
2846
2983
  // hit test may still see the motion's start.
2847
2984
  this.lockSelection(id, this.arena.participantsOf(id), target, this.arena.consumerOf(id) ?? null, consumerElement);
2848
2985
  }
2986
+ if (event.pointerType !== 'touch') {
2987
+ // The engine's own hit: the text its caret query and a drag select.
2988
+ this.noteSelectingPress(id, event.clientX, event.clientY, landed);
2989
+ }
2849
2990
  };
2850
2991
  onPointerMove = event => {
2851
2992
  if (event.pointerType === 'touch' && this.usesTouchEvents) {
@@ -2981,7 +3122,7 @@ export class GestureHost {
2981
3122
  const id = this.pointerIds.get(event.pointerId);
2982
3123
  if (id != null) {
2983
3124
  this.pointerIds.delete(event.pointerId);
2984
- this.unlockSelection(id);
3125
+ this.unlockSelection(id, true);
2985
3126
  this.retargeted.delete(id);
2986
3127
  this.arena.cancelled([id], eventTime(event));
2987
3128
  }
@@ -3185,7 +3326,7 @@ export class GestureHost {
3185
3326
  cancelEverything(time) {
3186
3327
  const ids = [...this.pointerIds.values()];
3187
3328
  for (const id of ids) {
3188
- this.unlockSelection(id);
3329
+ this.unlockSelection(id, true);
3189
3330
  }
3190
3331
  for (const identifier of [...this.touchIds.keys()]) {
3191
3332
  // The browser may keep the touch alive: its lift must not click.
@@ -1 +1 @@
1
- {"version":3,"file":"animator.d.ts","sourceRoot":"","sources":["../../src/motion/animator.ts"],"names":[],"mappings":"AAsLA,OAAO,EAAwB,KAAK,iBAAiB,EAAC,MAAM,UAAU,CAAC;AASvE;;GAEG;AACH,MAAM,MAAM,cAAc,GACxB,GAAG,GAAG,GAAG,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAAC;AAEzD;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC,cAAc,GAAG,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;AAE7E;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,4DAA4D;IAC5D,MAAM,EAAE,iBAAiB,CAAC;IAC1B;;;;OAIG;IACH,QAAQ,CAAC,EAAE,YAAY,CAAC;CACzB;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B;;;;OAIG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ;;;;;;OAMG;IACH,YA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G,IAAI,CAAC;IACzE,wEAAwE;IACxE,IAAI,CAAC,UAAU,CAAC,EAAE,aAAa,CAAC,cAAc,GAAG,OAAO,CAAC,GAAG,IAAI,CAAC;IACjE;;;OAGG;IACH,MAAM,CAAC,UAAU,CAAC,EAAE,aAAa,CAAC,cAAc,GAAG,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5E,uCAAuC;IACvC,OAAO,IAAI,IAAI,CAAC;CACjB;AAoKD;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,cAAc,EAAE,MAAM,CAO3D,CAAC;AAqEF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,WAAW,QAAS,CAAC;AAalC,oEAAoE;AACpE,eAAO,MAAM,mBAAmB,MAAM,CAAC;AA6CvC;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CACzB,OAAO,EAAE,WAAW,EACpB,OAAO,GAAE,eAAoB,GAC5B,QAAQ,CAaV;AAyED;;;;;;;;GAQG;AACH,wBAAgB,2BAA2B,IAAI,OAAO,CAMrD;AAED,kEAAkE;AAClE,wBAAgB,sBAAsB,IAAI,OAAO,CAMhD;AAWD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,cAAc,CAC5B,OAAO,EAAE,WAAW,GAAG,IAAI,EAC3B,OAAO,GAAE,eAAoB,GAC5B,QAAQ,CAk9FV"}
@@ -643,7 +643,7 @@ export function createAnimator(element, options = {}) {
643
643
  if (segment == null) {
644
644
  return null;
645
645
  }
646
- if (time >= segment.start + segment.duration) {
646
+ if (time >= endOf(property, segment)) {
647
647
  return null;
648
648
  }
649
649
  return segment;
@@ -676,6 +676,41 @@ export function createAnimator(element, options = {}) {
676
676
  start: segment.start + latest - segment.group.provisional
677
677
  };
678
678
 
679
+ /**
680
+ * When a waiting curve's call had its first frame, which put the curve on
681
+ * screen. Undefined for a curve that does not wait, or whose call has had
682
+ * no first frame.
683
+ */
684
+ const shownSince = (property, segment) => segment.group?.resolved === false ? segment.group.latest?.get(CHANNEL_OF[property]) : undefined;
685
+
686
+ /** A curve's end, dated from its call's first frame while it waits. */
687
+ const endOf = (property, segment) => (datedFromLatest(segment, shownSince(property, segment))?.start ?? segment.start) + segment.duration;
688
+
689
+ /**
690
+ * Takes a curve on screen out of the call that still waits for the
691
+ * browser's start. The curve keeps its course, dated from the call's first
692
+ * frame. A call that has no channel left starts at that frame.
693
+ */
694
+ const leaveWaitingCall = (segment, channel, latest) => {
695
+ const group = segment.group;
696
+ if (group == null) {
697
+ return;
698
+ }
699
+ const index = group.segments.indexOf(segment);
700
+ if (index >= 0) {
701
+ group.segments.splice(index, 1);
702
+ }
703
+ segment.start += latest - group.provisional;
704
+ segment.group = undefined;
705
+ if (!CHANNELS[channel].some(p => segments.get(p)?.group === group)) {
706
+ group.latest?.delete(channel);
707
+ group.channels.delete(channel);
708
+ }
709
+ if (group.channels.size === 0 && group.segments.length === 0) {
710
+ resolveGroup(group, latest);
711
+ }
712
+ };
713
+
679
714
  /**
680
715
  * The value on screen at `time`. Until the browser reports its start, a
681
716
  * held curve shows its first value. A frame that ran without that start
@@ -877,12 +912,25 @@ export function createAnimator(element, options = {}) {
877
912
  // Settled curves become resting values.
878
913
  for (const property of properties) {
879
914
  const segment = segments.get(property);
880
- if (segment != null && time >= segment.start + segment.duration) {
915
+ if (segment != null && time >= endOf(property, segment)) {
881
916
  resting[property] = segment.target;
882
917
  segments.delete(property);
883
918
  }
884
919
  }
885
920
  const moving = properties.filter(p => segments.has(p));
921
+ if (callGroup == null) {
922
+ // A call that starts now rebuilds a channel the compositor has moving
923
+ // since a first frame without a known start. The channel carries on
924
+ // from that frame, with a start of its own, instead of starting its
925
+ // curve again.
926
+ for (const property of moving) {
927
+ const segment = segments.get(property);
928
+ const latest = shownSince(property, segment);
929
+ if (latest != null) {
930
+ leaveWaitingCall(segment, channel, latest);
931
+ }
932
+ }
933
+ }
886
934
  // An explicit call can rebuild a channel while one of its curves still
887
935
  // waits for the browser's start. The animation then joins the current
888
936
  // call, or else that waiting call, with no start of its own.
@@ -1497,7 +1545,9 @@ export function createAnimator(element, options = {}) {
1497
1545
  for (const channel of start === 'commit' ? [] : channels) {
1498
1546
  for (const property of CHANNELS[channel]) {
1499
1547
  const segment = segments.get(property);
1500
- if (segment != null && time < segment.start + segment.duration && (segment.group == null || segment.group.resolved)) {
1548
+ // A call's first frame puts its channels on screen, even before the
1549
+ // browser reports the start. So such a channel is not at rest either.
1550
+ if (segment != null && time < endOf(property, segment) && (segment.group == null || segment.group.resolved || shownSince(property, segment) != null)) {
1501
1551
  return null;
1502
1552
  }
1503
1553
  }
@@ -2885,8 +2935,10 @@ export function createAnimator(element, options = {}) {
2885
2935
  }
2886
2936
  owners.add(segment.owner);
2887
2937
  // A curve still waiting for the browser's start stays in its call:
2888
- // it starts with that call's commit.
2889
- const group = segment.group != null && !segment.group.resolved ? segment.group : undefined;
2938
+ // it starts with that call's commit. A curve whose call had its first
2939
+ // frame is on screen already, so it leaves the call (leaveWaitingCall).
2940
+ const latest = shownSince(property, segment);
2941
+ const group = latest == null && segment.group != null && !segment.group.resolved ? segment.group : undefined;
2890
2942
  const replace = next => {
2891
2943
  if (group != null) {
2892
2944
  const index = group.segments.indexOf(segment);
@@ -2901,6 +2953,9 @@ export function createAnimator(element, options = {}) {
2901
2953
  if (segment.spring != null) {
2902
2954
  const from = valueAt(property, time) + delta;
2903
2955
  const velocity = velocityAt(property, time);
2956
+ if (latest != null) {
2957
+ leaveWaitingCall(segment, CHANNEL_OF[property], latest);
2958
+ }
2904
2959
  const curve = solveSpring(toSpring(segment.spring), {
2905
2960
  from,
2906
2961
  to: segment.target,
@@ -2920,6 +2975,9 @@ export function createAnimator(element, options = {}) {
2920
2975
  spring: segment.spring
2921
2976
  });
2922
2977
  } else {
2978
+ if (latest != null) {
2979
+ leaveWaitingCall(segment, CHANNEL_OF[property], latest);
2980
+ }
2923
2981
  replace({
2924
2982
  ...segment,
2925
2983
  target: segment.target + delta,
@@ -0,0 +1,58 @@
1
+ /**
2
+ * @file paging.ts
3
+ * @input A release velocity, a settle's start, end and velocity, and the UIKit
4
+ * paging constants
5
+ * @output Exports `pagingSettleVelocity`, `solvePaging` (UIKit's paging settle
6
+ * as a curve the animator plays) and `solveAnimatedPageScroll`
7
+ * @position Pure math, with no DOM and no React
8
+ *
9
+ * SYNC: When modified, update:
10
+ * - /packages/core/src/motion/paging.test.ts
11
+ * - /packages/core/src/motion/README.md
12
+ */
13
+ import type { MotionCurve } from './animator.js';
14
+ /**
15
+ * The velocity a paging settle starts at. It is the release velocity that every
16
+ * gesture reads, zeroed below `velocityFloor`. The page choice reads the
17
+ * release velocity itself.
18
+ */
19
+ export declare function pagingSettleVelocity(velocity: number): number;
20
+ /** A paging settle: the curve and where it ends. */
21
+ export interface PagingCurve extends MotionCurve {
22
+ readonly from: number;
23
+ readonly to: number;
24
+ /** Integration steps the settle took. */
25
+ readonly steps: number;
26
+ }
27
+ /**
28
+ * UIKit's paging settle from `from` (px), moving at `velocity` (px/s), onto
29
+ * `to`. It steps `paging.integrator` `stepsPerSecond` times a second and ends
30
+ * exactly on `to`. The same motion returns an overscrolled pager to its first
31
+ * or last page.
32
+ *
33
+ * Positions are content offsets along the paging axis, 0 at page 0 and growing
34
+ * toward later pages. Velocities are px/s of that offset.
35
+ *
36
+ * No closed form reproduces the per-frame stepping, so the settle integrates
37
+ * once into a table, and the curve reads the table. A release needs at most
38
+ * about 400 steps, well under a millisecond of work.
39
+ *
40
+ * The release velocity enters in px per millisecond per step, as UIKit hands it
41
+ * to the integrator. At 960 steps a second, the content starts at 96 % of the
42
+ * finger's speed, as in UIKit.
43
+ */
44
+ export declare function solvePaging({ from, velocity, to, }: {
45
+ from: number;
46
+ velocity: number;
47
+ to: number;
48
+ }): PagingCurve;
49
+ /**
50
+ * `setContentOffset(_:animated:)`: `paging.animatedScroll.duration` on a
51
+ * sinusoidal ease-in-out, whatever the distance. UIKit starts it from the
52
+ * current offset and drops any velocity, as here.
53
+ */
54
+ export declare function solveAnimatedPageScroll({ from, to, }: {
55
+ from: number;
56
+ to: number;
57
+ }): MotionCurve;
58
+ //# sourceMappingURL=paging.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paging.d.ts","sourceRoot":"","sources":["../../src/motion/paging.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,YAAY,CAAC;AAG5C;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAE7D;AAED,oDAAoD;AACpD,MAAM,WAAW,WAAY,SAAQ,WAAW;IAC9C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,yCAAyC;IACzC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,WAAW,CAAC,EAC1B,IAAI,EACJ,QAAQ,EACR,EAAE,GACH,EAAE;IACD,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,EAAE,EAAE,MAAM,CAAC;CACZ,GAAG,WAAW,CA6Cd;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,EACtC,IAAI,EACJ,EAAE,GACH,EAAE;IACD,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;CACZ,GAAG,WAAW,CAmBd"}