@ng-native/components 0.25.0 → 0.26.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.
@@ -1,12 +1,13 @@
1
1
  import { Component, DestroyRef, Directive, ElementRef, TemplateRef, afterEveryRender, booleanAttribute, computed, contentChild, effect, inject, input, linkedSignal, output, signal, untracked, viewChild, } from '@angular/core';
2
- import { nativePlatform, pinnedRange, } from '@ng-native/fabric';
2
+ import { nativePlatform, } from '@ng-native/fabric';
3
3
  import { HeightIndex } from "./height-index.js";
4
4
  import { dismissKeyboardOnTap } from "./keyboard-taps.js";
5
5
  import { RefreshControl } from "./refresh-control.js";
6
- import { STICKY_SETTLE_MS } from "./sticky-headers.js";
6
+ import { StickyRows } from "./sticky-rows.js";
7
7
  import { TemplateSlot } from "./template-slot.js";
8
8
  import { ZeroSizeWarning, checksZeroSize, written } from "./zero-size-warning.js";
9
9
  import { View } from "./view.js";
10
+ import { VIRTUAL_LIST_LAYOUT } from "./virtual-list-layout.js";
10
11
  import { ScrollViewProps } from "./scroll-view-props.js";
11
12
  import { numberOr } from "./transforms.js";
12
13
  import * as i0 from "@angular/core";
@@ -50,6 +51,8 @@ const HOLD_TOLERANCE = 0.5;
50
51
  * viewport: FlatList's `updateCellsBatchingPeriod`.
51
52
  */
52
53
  const FILL_BATCH_MS = 50;
54
+ /** How long without a scroll event counts as the scroll having stopped. */
55
+ const PAUSE_MS = 200;
53
56
  /**
54
57
  * Windowed list: a native scroll view whose content is sized to the full list, with only the
55
58
  * visible slice rendered. Commits as `RCTScrollView`.
@@ -165,9 +168,17 @@ export class VirtualList extends ScrollViewProps {
165
168
  * up to `windowSize - 1` more around it. While the JS thread is
166
169
  * idle the window grows a viewport at a time, ahead of the scroll direction first, so a fling
167
170
  * lands on rows already drawn. About two-thirds of the extra viewports go ahead of the scroll and
168
- * the rest behind. `1` renders the visible rows and the overscan only.
171
+ * the rest behind. `1` fills no extra viewports, though a fast scroll still renders ahead of
172
+ * itself unless `velocityLead` is `0`.
169
173
  */
170
174
  windowSize = input(5, { ...(ngDevMode ? { debugName: "windowSize" } : /* istanbul ignore next */ {}), transform: numberOr(5) });
175
+ /**
176
+ * How far past the viewport a scroll renders in the direction it is going, in milliseconds of
177
+ * its speed, up to three viewports: the rows the list will reach by the time a window change has
178
+ * been through JavaScript and back to native. `0` renders only the visible rows, the overscan
179
+ * and the fill.
180
+ */
181
+ velocityLead = input(500, { ...(ngDevMode ? { debugName: "velocityLead" } : /* istanbul ignore next */ {}), transform: numberOr(500) });
171
182
  /** How close to the end, in viewport heights, `(endReached)` fires. RN's default is 2. */
172
183
  endReachedThreshold = input(2, { ...(ngDevMode ? { debugName: "endReachedThreshold" } : /* istanbul ignore next */ {}), transform: numberOr(2) });
173
184
  /** Lay the rows out along x instead of y, and scroll that way. */
@@ -196,9 +207,6 @@ export class VirtualList extends ScrollViewProps {
196
207
  viewableItemsChanged = output();
197
208
  viewport = signal(0, /* @ts-ignore */
198
209
  ...(ngDevMode ? [{ debugName: "viewport" }] : /* istanbul ignore next */ []));
199
- /** The leading edge of the viewport in content space, which sticky rows and viewability need. */
200
- offset = signal(0, /* @ts-ignore */
201
- ...(ngDevMode ? [{ debugName: "offset" }] : /* istanbul ignore next */ []));
202
210
  headerHeight = signal(0, /* @ts-ignore */
203
211
  ...(ngDevMode ? [{ debugName: "headerHeight" }] : /* istanbul ignore next */ []));
204
212
  /** What native reported the content measures along the axis, once it has. */
@@ -220,17 +228,6 @@ export class VirtualList extends ScrollViewProps {
220
228
  /** See ScrollView: inside Android's swipe layout the list must see a drag first. */
221
229
  nestedScroll = computed(() => nativePlatform() === 'android' && this.refreshControl() ? true : undefined, /* @ts-ignore */
222
230
  ...(ngDevMode ? [{ debugName: "nestedScroll" }] : /* istanbul ignore next */ []));
223
- /**
224
- * Whether native moves sticky rows. Each then stays at its own place in the list and native
225
- * translates it on every frame the list scrolls, as RN's `ScrollViewStickyHeader` does; a
226
- * translate committed from each scroll event lands a frame or more late, and on a fast fling
227
- * the row shudders and comes away from the edge.
228
- */
229
- nativeSticky = this.engine.drivesScroll;
230
- /** The offset once scrolling pauses, which the settled translate of a native-moved row is from. */
231
- settled = signal(0, /* @ts-ignore */
232
- ...(ngDevMode ? [{ debugName: "settled" }] : /* istanbul ignore next */ []));
233
- settleTimer;
234
231
  /** Viewports filled past the overscan, before and after the visible rows in index order. */
235
232
  fill = signal({ before: 0, after: 0 }, /* @ts-ignore */
236
233
  ...(ngDevMode ? [{ debugName: "fill" }] : /* istanbul ignore next */ []));
@@ -249,12 +246,21 @@ export class VirtualList extends ScrollViewProps {
249
246
  }, /* @ts-ignore */
250
247
  ...(ngDevMode ? [{ debugName: "reach" }] : /* istanbul ignore next */ []));
251
248
  fillTimer;
252
- /** What native is moving, by row view, with the transform kept beside the translate. */
253
- drives = new Map();
254
249
  canvasView = viewChild.required('rows', { ...(ngDevMode ? { debugName: "canvasView" } : /* istanbul ignore next */ {}), read: ElementRef });
255
- /** Whether the scroll offset is needed as a signal, which only pinning needs. */
256
- pinning = computed(() => this.stickyHeader() || this.stickyIndices().length > 0, /* @ts-ignore */
257
- ...(ngDevMode ? [{ debugName: "pinning" }] : /* istanbul ignore next */ []));
250
+ /** The sticky rows and header: see `StickyRows`. */
251
+ sticky = new StickyRows(this.engine, this.node, {
252
+ indices: this.stickyIndices,
253
+ header: this.stickyHeader,
254
+ headerHeight: this.headerHeight,
255
+ horizontal: () => this.horizontal(),
256
+ measuring: () => this.measuring(),
257
+ topOf: (index) => this.topOf(index),
258
+ heightOf: (index) => this.heightOf(index),
259
+ slotStyle: (index) => this.slotStyle(index),
260
+ flowSpacing: () => this.flowSpacing(),
261
+ flip: () => this.flip(),
262
+ flipText: () => this.flipText(),
263
+ });
258
264
  /** Rows size themselves and are laid out in flow, rather than placed at a known offset. */
259
265
  measuring = computed(() => this.itemHeight() === undefined, /* @ts-ignore */
260
266
  ...(ngDevMode ? [{ debugName: "measuring" }] : /* istanbul ignore next */ []));
@@ -277,6 +283,74 @@ export class VirtualList extends ScrollViewProps {
277
283
  return this.horizontal() ? { top, bottom } : { left, right };
278
284
  }, /* @ts-ignore */
279
285
  ...(ngDevMode ? [{ debugName: "across" }] : /* istanbul ignore next */ []));
286
+ /** How items are laid out across the width, when a directive on the list says: see the token. */
287
+ columnLayout = inject(VIRTUAL_LIST_LAYOUT, { self: true, optional: true });
288
+ /**
289
+ * Items to a line. Only for a vertical list whose rows have known heights: a line's height
290
+ * would otherwise wait on every item in it measuring, and FlatList's `numColumns` is vertical
291
+ * only too. The directive says so in development.
292
+ */
293
+ columns = computed(() => {
294
+ const columns = this.columnLayout?.columns() ?? 1;
295
+ return this.measuring() || this.horizontal() ? 1 : columns;
296
+ }, /* @ts-ignore */
297
+ ...(ngDevMode ? [{ debugName: "columns" }] : /* istanbul ignore next */ []));
298
+ /** Which line each item is on, when there is more than one to a line. */
299
+ lines = computed(() => {
300
+ const columns = this.columns();
301
+ if (columns === 1)
302
+ return null;
303
+ const count = this.items().length;
304
+ const sticky = this.sticky.next();
305
+ const of = new Int32Array(count);
306
+ const starts = [];
307
+ let column = columns;
308
+ for (let i = 0; i < count; i++) {
309
+ const alone = sticky.has(i);
310
+ if (alone || column === columns) {
311
+ starts.push(i);
312
+ column = 0;
313
+ }
314
+ of[i] = starts.length - 1;
315
+ column = alone ? columns : column + 1;
316
+ }
317
+ return { of, starts };
318
+ }, /* @ts-ignore */
319
+ ...(ngDevMode ? [{ debugName: "lines" }] : /* istanbul ignore next */ []));
320
+ /** The props across each column, built once per change of columns, gap or padding. */
321
+ columnAcross = computed(() => {
322
+ const layout = this.columnLayout;
323
+ if (!layout || !this.lines())
324
+ return [];
325
+ const { left, right } = this.edges();
326
+ return Array.from({ length: this.columns() }, (_, column) => layout.across(column, left, right));
327
+ }, /* @ts-ignore */
328
+ ...(ngDevMode ? [{ debugName: "columnAcross" }] : /* istanbul ignore next */ []));
329
+ /** An item's insets across the axis: its column's, or the whole width's. */
330
+ acrossOf(index) {
331
+ const lines = this.lines();
332
+ if (!lines || this.sticky.next().has(index))
333
+ return this.across();
334
+ return this.columnAcross()[index - lines.starts[lines.of[index]]];
335
+ }
336
+ /** The line an item is on: the item itself, when each has a line to itself. */
337
+ lineOf(index) {
338
+ const lines = this.lines();
339
+ // An index past the items, a sticky one given for rows not there yet, is past the last line.
340
+ return lines ? (lines.of[index] ?? lines.starts.length) : index;
341
+ }
342
+ /** Whether a row is on the list's last line, which no separator comes after. */
343
+ onLastLine(index) {
344
+ const lines = this.lines();
345
+ return lines ? lines.of[index] === lines.starts.length - 1 : index >= this.items().length - 1;
346
+ }
347
+ /** The first item on a line, or the item count for a line past the last. */
348
+ lineStart(line) {
349
+ const lines = this.lines();
350
+ if (!lines)
351
+ return Math.min(line, this.items().length);
352
+ return line < lines.starts.length ? lines.starts[line] : this.items().length;
353
+ }
280
354
  /** Heights native has reported, by key. */
281
355
  measured = new Map();
282
356
  /** Bumped when a measurement changes, which is what re-sizes the list. */
@@ -299,14 +373,25 @@ export class VirtualList extends ScrollViewProps {
299
373
  */
300
374
  table = computed(() => {
301
375
  const height = this.itemHeight();
302
- if (typeof height === 'number')
376
+ const lines = this.lines();
377
+ if (typeof height === 'number' && !lines)
303
378
  return null;
304
379
  // Each row's entry is its size and the gap after it, so where a row starts counts the gaps
305
380
  // before it without a second table.
306
381
  const gap = this.rowGap();
307
382
  const items = this.items();
383
+ if (lines) {
384
+ // An entry a line, as tall as the tallest item on it.
385
+ const sizes = new Float64Array(lines.starts.length);
386
+ for (let i = 0; i < items.length; i++) {
387
+ const size = (typeof height === 'function' ? height(items[i], i) : height) + gap;
388
+ const line = lines.of[i];
389
+ sizes[line] = Math.max(sizes[line], size);
390
+ }
391
+ return new HeightIndex(sizes);
392
+ }
308
393
  const sizes = new Float64Array(items.length);
309
- if (height) {
394
+ if (typeof height === 'function') {
310
395
  for (let i = 0; i < items.length; i++)
311
396
  sizes[i] = height(items[i], i) + gap;
312
397
  return new HeightIndex(sizes);
@@ -405,23 +490,26 @@ export class VirtualList extends ScrollViewProps {
405
490
  return flip ? { ...spacing, transform: flip } : spacing;
406
491
  }, /* @ts-ignore */
407
492
  ...(ngDevMode ? [{ debugName: "flowStyle" }] : /* istanbul ignore next */ []));
408
- /** Top of a row: the leading padding, and every row and gap before it. */
493
+ /** Top of a row: the leading padding, and every row and gap before it. In columns, its line's. */
409
494
  topOf(index) {
410
495
  const table = this.layout();
411
- return this.lead() + (table ? table.topOf(index) : index * this.stride());
496
+ return this.lead() + (table ? table.topOf(this.lineOf(index)) : index * this.stride());
412
497
  }
413
- /** A row's own size, without the gap after it. */
498
+ /** A row's own size, without the gap after it. In columns, its line's. */
414
499
  heightOf(index) {
415
500
  const table = this.layout();
416
- return table ? table.heightOf(index) - this.rowGap() : this.itemHeight();
501
+ if (!table)
502
+ return this.itemHeight();
503
+ return table.heightOf(this.lineOf(index)) - this.rowGap();
417
504
  }
418
- /** First row whose bottom, or the gap after it, is past `y`. */
505
+ /** First row whose bottom, or the gap after it, is past `y`. In columns, the first on its line. */
419
506
  indexAt(y) {
420
507
  const table = this.layout();
421
508
  const along = y - this.lead();
422
509
  if (!table)
423
510
  return Math.max(0, Math.floor(along / this.stride()));
424
- return table.indexAt(along);
511
+ const at = table.indexAt(along);
512
+ return this.lines() ? this.lineStart(at) : at;
425
513
  }
426
514
  // --- holding position -------------------------------------------------------------------
427
515
  /** The row the viewport's leading edge is in, taken at each scroll. */
@@ -479,13 +567,28 @@ export class VirtualList extends ScrollViewProps {
479
567
  return this.showStart();
480
568
  if (index < 0)
481
569
  return this.atOffset();
482
- const held = this.topOf(index) + anchor.within;
570
+ // No further than the content lets native scroll, past the footer and the inset after it:
571
+ // Android stops a scroll there and iOS would show blank space past it, and the window must be
572
+ // built for where it is. Not cut at the start, where an inset before the rows, or a bounce,
573
+ // puts native above zero.
574
+ const header = this.headerHeight();
575
+ const want = this.topOf(index) + anchor.within;
576
+ const held = Math.min(want, this.reachable(header + want) - header);
483
577
  if (Math.abs(held - this.lastOffset) > HOLD_TOLERANCE) {
484
578
  this.pendingScroll = { offset: held, animated: false };
485
579
  this.lastOffset = held;
486
580
  }
487
- this.anchor = { ...anchor, items, index };
488
- return index;
581
+ // The window is built from the row the held offset lands in, which is not the anchored one
582
+ // when that row came out shorter than the way into it: a new column count can move an item
583
+ // off a line made tall by another item, onto a short one.
584
+ // In a single column the anchored row is kept, so a row scrolled to stays held there.
585
+ const top = this.lines() ? Math.max(0, Math.min(this.indexAt(held), items.length - 1)) : index;
586
+ if (top === index) {
587
+ this.anchor = { ...anchor, items, index };
588
+ return index;
589
+ }
590
+ this.anchorAt(top, held);
591
+ return top;
489
592
  }
490
593
  /**
491
594
  * The row under the offset native is still at, in rows that have just replaced the old ones, as
@@ -567,18 +670,22 @@ export class VirtualList extends ScrollViewProps {
567
670
  super();
568
671
  afterEveryRender(() => {
569
672
  this.flushScroll();
570
- if (this.nativeSticky)
673
+ if (this.sticky.native)
571
674
  this.driveStickyRows();
572
675
  this.recheckItems();
573
676
  });
677
+ // Not a host `(scroll)` listener: Angular marks every view above one dirty on each event, so a
678
+ // fling would check the whole screen every frame. What a scroll changes is in signals, which
679
+ // schedule the views that read them.
680
+ const stopScroll = this.engine.setEventListener(this.node, 'topScroll', (event) => this.onScroll(event));
574
681
  const stop = dismissKeyboardOnTap(this.engine, this.node, () => this.keyboardShouldPersistTaps());
575
682
  inject(DestroyRef).onDestroy(() => {
683
+ stopScroll();
576
684
  stop();
577
- clearTimeout(this.settleTimer);
685
+ this.sticky.destroy();
578
686
  clearTimeout(this.fillTimer);
687
+ clearTimeout(this.speedTimer);
579
688
  this.zeroSize?.stop();
580
- for (const held of this.drives.values())
581
- held.drive.stop();
582
689
  });
583
690
  if (this.zeroSize)
584
691
  this.checkZeroSize(this.zeroSize);
@@ -586,6 +693,8 @@ export class VirtualList extends ScrollViewProps {
586
693
  }
587
694
  /** The items the end and viewability were last checked against after a render. */
588
695
  checkedItems = null;
696
+ /** And the table placing them, which a new column count makes again for the same items. */
697
+ checkedTable = null;
589
698
  /**
590
699
  * New items can bring the end within reach or change what is on screen with no scroll: a list
591
700
  * shorter than its viewport, a page appended while at the end, a filter. Checked once the rows
@@ -593,9 +702,11 @@ export class VirtualList extends ScrollViewProps {
593
702
  */
594
703
  recheckItems() {
595
704
  const items = this.items();
596
- if (items === this.checkedItems)
705
+ const table = this.table();
706
+ if (items === this.checkedItems && table === this.checkedTable)
597
707
  return;
598
708
  this.checkedItems = items;
709
+ this.checkedTable = table;
599
710
  this.checkEnd(this.headerHeight() + this.lastOffset);
600
711
  this.announceViewable(this.lastOffset);
601
712
  }
@@ -620,12 +731,15 @@ export class VirtualList extends ScrollViewProps {
620
731
  const overscan = this.overscan();
621
732
  if (!items.length)
622
733
  return null;
623
- const visible = Math.min(this.visible(), items.length - 1);
734
+ // Counted in lines, which are rows unless items are in columns.
735
+ const line = this.lineOf(Math.min(this.visible(), items.length - 1));
736
+ const visible = this.lineStart(line);
624
737
  // In viewports, so nothing before the first layout.
625
738
  const fill = this.reach();
626
739
  // Before the first layout we have no viewport, so render a screen's worth optimistically
627
740
  // rather than nothing: an empty first frame is worse than a few extra rows.
628
- const budget = viewport > 0 ? viewport : this.heightOf(Math.max(0, visible - overscan)) * overscan * 2;
741
+ const overscanned = this.lineStart(Math.max(0, line - overscan));
742
+ const budget = viewport > 0 ? viewport : this.heightOf(overscanned) * overscan * 2;
629
743
  /*
630
744
  * Measured from the top of the first *visible* row, not the first rendered one.
631
745
  *
@@ -635,8 +749,11 @@ export class VirtualList extends ScrollViewProps {
635
749
  * then the rows added below happened to be worth exactly the rows wasted above. With mixed
636
750
  * heights they are not, and the list clips short of its own bottom.
637
751
  */
752
+ // Within three viewports of the viewport as it is now, which may have shrunk since.
753
+ const reach = 3 * Math.max(0, viewport);
754
+ const ahead = this.velocityLead() ? Math.max(-reach, Math.min(reach, this.ahead())) : 0;
638
755
  const top = this.topOf(visible);
639
- const first = Math.max(0, Math.min(visible - overscan, this.indexAt(top - fill.before * viewport)));
756
+ const first = Math.max(0, Math.min(overscanned, this.indexAt(top - fill.before * viewport - Math.max(0, -ahead))));
640
757
  let last = visible;
641
758
  while (last < items.length && this.topOf(last) < top + budget)
642
759
  last++;
@@ -647,8 +764,13 @@ export class VirtualList extends ScrollViewProps {
647
764
  * from the scroll offset instead, the window would change on every scroll event rather than
648
765
  * when the visible row does.
649
766
  */
650
- let end = Math.min(items.length, last + overscan);
651
- const deepest = top + this.heightOf(visible) + this.rowGap() + budget + fill.after * viewport;
767
+ let end = last < items.length ? this.lineStart(this.lineOf(last) + overscan) : items.length;
768
+ const deepest = top +
769
+ this.heightOf(visible) +
770
+ this.rowGap() +
771
+ budget +
772
+ fill.after * viewport +
773
+ Math.max(0, ahead);
652
774
  while (end < items.length && this.topOf(end) < deepest)
653
775
  end++;
654
776
  return { first, last: end };
@@ -678,9 +800,9 @@ export class VirtualList extends ScrollViewProps {
678
800
  spacer = computed(() => {
679
801
  const span = this.span();
680
802
  let lead = span ? this.topOf(span.first) : 0;
681
- const pinned = this.pinnedIndex();
803
+ const pinned = this.sticky.pinned();
682
804
  if (span && pinned !== null && pinned < span.first) {
683
- lead = this.nativeSticky ? this.topOf(pinned) : lead - this.heightOf(pinned) - this.rowGap();
805
+ lead = this.sticky.native ? this.topOf(pinned) : lead - this.heightOf(pinned) - this.rowGap();
684
806
  }
685
807
  return this.horizontal() ? { width: Math.max(0, lead) } : { height: Math.max(0, lead) };
686
808
  }, /* @ts-ignore */
@@ -688,7 +810,7 @@ export class VirtualList extends ScrollViewProps {
688
810
  /** The rows from `first` up to `last`, and the pinned row above them if there is one. */
689
811
  rowsFor(items, first, last) {
690
812
  const rows = [];
691
- const pinned = this.pinnedIndex();
813
+ const pinned = this.sticky.pinned();
692
814
  const pinnedAbove = pinned !== null && pinned < first;
693
815
  this.releaseRecycled(first, last, pinnedAbove ? pinned : null);
694
816
  // The pinned row is on screen even when its own place in the list is not, which is the whole
@@ -700,11 +822,11 @@ export class VirtualList extends ScrollViewProps {
700
822
  slot: this.recycledSlot(key, items[pinned], pinned),
701
823
  key,
702
824
  item: items[pinned],
703
- style: this.nativeSticky
704
- ? this.stickyStyle(pinned)
825
+ style: this.sticky.native
826
+ ? this.sticky.style(pinned)
705
827
  : this.measuring()
706
- ? this.pinnedFlowStyle(this.topOf(first) - this.heightOf(pinned) - this.rowGap())
707
- : this.slotStyle(pinned, this.offset()),
828
+ ? this.sticky.flowStyle(this.topOf(first) - this.heightOf(pinned) - this.rowGap())
829
+ : this.slotStyle(pinned, this.sticky.offset()),
708
830
  }));
709
831
  }
710
832
  for (let index = first; index < last; index++) {
@@ -717,7 +839,7 @@ export class VirtualList extends ScrollViewProps {
717
839
  style: this.styleFor(index, index === pinned),
718
840
  }));
719
841
  }
720
- if (pinnedAbove && this.nativeSticky && this.measuring())
842
+ if (pinnedAbove && this.sticky.native && this.measuring())
721
843
  this.leadWindow(rows, pinned, first);
722
844
  return rows;
723
845
  }
@@ -736,98 +858,23 @@ export class VirtualList extends ScrollViewProps {
736
858
  rows[1] = this.hold({ ...lead, style: { ...lead.style, [margin]: between } });
737
859
  }
738
860
  styleFor(index, pinned) {
739
- if (this.nativeSticky && this.nextSticky().has(index))
740
- return this.stickyStyle(index);
861
+ if (this.sticky.native && this.sticky.next().has(index))
862
+ return this.sticky.style(index);
741
863
  if (this.measuring()) {
742
- return pinned ? this.pinnedFlowStyle(this.topOf(index)) : this.flowStyle();
864
+ return pinned ? this.sticky.flowStyle(this.topOf(index)) : this.flowStyle();
743
865
  }
744
- return pinned ? this.slotStyle(index, this.offset()) : this.slotStyle(index);
745
- }
746
- /** A pinned row in flow, moved from where flow put it to the leading edge by a transform. */
747
- pinnedFlowStyle(at) {
748
- const shift = Math.max(0, this.offset() - at);
749
- const move = `${this.horizontal() ? 'translateX' : 'translateY'}(${shift}px)`;
750
- const flip = this.flipText();
751
- return { ...this.flowSpacing(), zIndex: 1, transform: flip ? `${move} ${flip}` : move };
866
+ return pinned ? this.slotStyle(index, this.sticky.offset()) : this.slotStyle(index);
752
867
  }
753
868
  /**
754
- * A sticky row native moves: at its own place, with the translate native had reached when
755
- * scrolling paused, so the props agree with what is on screen.
756
- */
757
- stickyStyle(index) {
758
- const horizontal = this.horizontal();
759
- const style = this.measuring()
760
- ? { ...this.flowSpacing() }
761
- : { ...this.slotStyle(index) };
762
- style['zIndex'] = 1;
763
- const top = this.topOf(index);
764
- const shift = Math.min(Math.max(0, this.settled() - top), this.stopOf(index) - top);
765
- const move = shift > 0 ? `${horizontal ? 'translateX' : 'translateY'}(${shift}px)` : '';
766
- const transform = [move, this.flipText() ?? ''].filter(Boolean).join(' ');
767
- if (transform)
768
- style['transform'] = transform;
769
- return style;
770
- }
771
- /** Each sticky row, and the one after it, which pushes it off. */
772
- nextSticky = computed(() => {
773
- const sticky = this.stickyIndices();
774
- return new Map(sticky.map((index, at) => [index, sticky[at + 1]]));
775
- }, /* @ts-ignore */
776
- ...(ngDevMode ? [{ debugName: "nextSticky" }] : /* istanbul ignore next */ []));
777
- /** Where a sticky row stops, pushed off by the next: that row's top, less this row's size. */
778
- stopOf(index) {
779
- const next = this.nextSticky().get(index);
780
- return next === undefined ? Infinity : this.topOf(next) - this.heightOf(index);
781
- }
782
- /**
783
- * How native moves a rendered row, or null when it does not: along the scroll view's own
784
- * offset, which counts the header, from the row's top until the next sticky row pushes it off.
785
- */
786
- stickyDrive(row) {
787
- if (!this.nativeSticky || row.parked || !this.nextSticky().has(row.index))
788
- return null;
789
- const header = this.headerHeight();
790
- const start = header + this.topOf(row.index);
791
- return {
792
- range: pinnedRange(start, header + this.stopOf(row.index)),
793
- statics: this.flip() ?? [],
794
- };
795
- }
796
- /**
797
- * Hand each rendered sticky row's view to native to move, and let go of the rest. The rows'
798
- * views are the canvas's element children in window order, after the spacer, which is how
799
- * `@for` over `window()` leaves them.
869
+ * Hand each rendered sticky row's view to native to move. The rows' views are the canvas's
870
+ * element children in window order, after the spacer, which is how `@for` over `window()`
871
+ * leaves them.
800
872
  */
801
873
  driveStickyRows() {
802
- if (!this.pinning() && this.drives.size === 0)
803
- return;
804
- const canvas = this.canvasView().nativeElement;
805
- const views = canvas.childList
874
+ const views = () => this.canvasView().nativeElement.childList
806
875
  .filter((child) => child.nodeKind === 'element')
807
876
  .slice(this.measuring() ? 1 : 0);
808
- const axis = this.horizontal() ? 'x' : 'y';
809
- const live = new Set();
810
- this.window().forEach((row, at) => {
811
- const view = views[at];
812
- const next = this.stickyDrive(row);
813
- if (!view || !next)
814
- return;
815
- live.add(view);
816
- const statics = JSON.stringify(next.statics);
817
- const held = this.drives.get(view);
818
- if (held?.statics === statics)
819
- return held.drive.update(next.range);
820
- held?.drive.stop();
821
- const drive = this.engine.driveByScroll(view, this.node, axis, next.range, next.statics);
822
- if (drive)
823
- this.drives.set(view, { drive, statics });
824
- });
825
- for (const [view, held] of this.drives) {
826
- if (live.has(view))
827
- continue;
828
- held.drive.stop();
829
- this.drives.delete(view);
830
- }
877
+ this.sticky.drive(() => this.window(), views);
831
878
  }
832
879
  /** Which recycling slot each rendered item holds, by key: its type, and the row it last drew. */
833
880
  recycled = new Map();
@@ -880,10 +927,14 @@ export class VirtualList extends ScrollViewProps {
880
927
  return { index: -1, slot, key, item: this.items()[0], style: PARKED };
881
928
  }
882
929
  recycledSlot(key, item, index) {
930
+ // A sticky row is a type of its own: native keeps the translate it moved one by, and a plain
931
+ // row taking its slot commits no transform to put it back. A row that stops or starts being
932
+ // sticky takes a new slot for the same reason.
933
+ const sticky = this.sticky.next().has(index);
883
934
  const held = this.recycled.get(key);
884
- if (held)
935
+ if (held && this.sticky.isType(held.type) === sticky)
885
936
  return held.slot;
886
- const type = this.itemType()?.(item, index);
937
+ const type = this.sticky.recyclingType(index, this.itemType()?.(item, index));
887
938
  const slot = this.unpark(key, type) ?? this.parked.get(type)?.pop()?.slot ?? this.nextSlot++;
888
939
  this.recycled.set(key, { slot, type, row: null });
889
940
  return slot;
@@ -947,12 +998,13 @@ export class VirtualList extends ScrollViewProps {
947
998
  const items = this.items();
948
999
  const gaps = [];
949
1000
  for (const row of this.window()) {
950
- if (row.parked || row.index >= items.length - 1)
1001
+ if (row.parked || this.onLastLine(row.index))
951
1002
  continue;
952
1003
  const style = this.measuring() ? this.measuredGapStyle(row) : this.gapStyle(row);
953
1004
  if (!style)
954
1005
  continue;
955
- const trailingItem = items[row.index + 1];
1006
+ // What follows it along the list: the next line's first item, not the one beside it.
1007
+ const trailingItem = items[this.lineStart(this.lineOf(row.index) + 1)];
956
1008
  gaps.push({
957
1009
  index: row.index,
958
1010
  style,
@@ -1011,23 +1063,8 @@ export class VirtualList extends ScrollViewProps {
1011
1063
  this.measuredGaps.clear();
1012
1064
  return style;
1013
1065
  }
1014
- /**
1015
- * The header's translation while it is pinned: the scroll position, held back at zero by an
1016
- * overscroll and at the first sticky row, which pushes it off.
1017
- */
1018
- headerStyle = computed(() => {
1019
- const flip = this.flipText();
1020
- if (!this.stickyHeader())
1021
- return flip ? { transform: flip } : undefined;
1022
- const along = this.offset() + this.headerHeight();
1023
- const first = this.stickyIndices()[0];
1024
- const limit = first === undefined ? Infinity : this.topOf(first);
1025
- const shift = Math.min(Math.max(0, along), limit);
1026
- const move = shift > 0 ? `${this.horizontal() ? 'translateX' : 'translateY'}(${shift}px)` : '';
1027
- const transform = [move, flip ?? ''].filter(Boolean).join(' ');
1028
- return transform ? { zIndex: 1, transform } : { zIndex: 1 };
1029
- }, /* @ts-ignore */
1030
- ...(ngDevMode ? [{ debugName: "headerStyle" }] : /* istanbul ignore next */ []));
1066
+ /** The header, pinned with the rows when `stickyHeader` says so: see `StickyRows`. */
1067
+ headerStyle = this.sticky.headerStyle;
1031
1068
  /**
1032
1069
  * The footer, flipped back like every row when the list is inverted, as FlatList inverts its
1033
1070
  * header and footer cells too; otherwise both read upside down.
@@ -1037,25 +1074,6 @@ export class VirtualList extends ScrollViewProps {
1037
1074
  return flip ? { transform: flip } : undefined;
1038
1075
  }, /* @ts-ignore */
1039
1076
  ...(ngDevMode ? [{ debugName: "footerStyle" }] : /* istanbul ignore next */ []));
1040
- /**
1041
- * The sticky row currently holding the leading edge: the last one at or before the offset.
1042
- * Null when the list has scrolled back above the first of them.
1043
- */
1044
- pinnedIndex = computed(() => {
1045
- const sticky = this.stickyIndices();
1046
- if (sticky.length === 0)
1047
- return null;
1048
- const offset = this.offset();
1049
- let pinned = null;
1050
- for (const index of sticky) {
1051
- if (this.topOf(index) <= offset)
1052
- pinned = index;
1053
- else
1054
- break;
1055
- }
1056
- return pinned;
1057
- }, /* @ts-ignore */
1058
- ...(ngDevMode ? [{ debugName: "pinnedIndex" }] : /* istanbul ignore next */ []));
1059
1077
  /** Which rows are on screen far enough to count, by the caller's threshold. */
1060
1078
  viewableAt(offset) {
1061
1079
  const viewport = this.viewport();
@@ -1126,7 +1144,8 @@ export class VirtualList extends ScrollViewProps {
1126
1144
  this.lastOffset = offset;
1127
1145
  this.anchor = { key: this.keyAt(index), within, items, index };
1128
1146
  this.jumpTo(index);
1129
- this.moveTo(index);
1147
+ // The start of its line, which is what a scroll event there gives, so the fill keeps its way.
1148
+ this.moveTo(this.lineStart(this.lineOf(index)));
1130
1149
  this.scrollToOffset({ offset: this.headerHeight() + offset, animated: options.animated });
1131
1150
  }
1132
1151
  /** Scroll to an offset along the list's own axis: x when it is horizontal, y otherwise. */
@@ -1134,9 +1153,11 @@ export class VirtualList extends ScrollViewProps {
1134
1153
  const { offset, animated = true } = options;
1135
1154
  this.jumpTo(this.indexAt(offset - this.headerHeight()));
1136
1155
  const [x, y] = this.horizontal() ? [offset, 0] : [0, offset];
1156
+ this.sticky.jumping(this.reachable(offset), animated);
1137
1157
  this.engine.dispatchCommand(this.node, 'scrollTo', [x, y, animated]);
1138
1158
  }
1139
1159
  scrollToEnd(options = {}) {
1160
+ this.sticky.jumping(this.reachable(Infinity), options.animated ?? true);
1140
1161
  this.jumpTo(this.items().length - 1);
1141
1162
  this.engine.dispatchCommand(this.node, 'scrollToEnd', [options.animated ?? true]);
1142
1163
  }
@@ -1147,7 +1168,7 @@ export class VirtualList extends ScrollViewProps {
1147
1168
  const key = horizontal ? 'left' : 'top';
1148
1169
  const extent = horizontal ? 'width' : 'height';
1149
1170
  const flip = this.flipText();
1150
- const across = this.across();
1171
+ const across = this.acrossOf(index);
1151
1172
  let style = this.slots.get(index);
1152
1173
  // The flip is part of the comparison because turning the list over changes every row, and a
1153
1174
  // cached slot would otherwise keep the orientation it was built with.
@@ -1176,21 +1197,66 @@ export class VirtualList extends ScrollViewProps {
1176
1197
  // window is built, so that both edges can be measured from the same place.
1177
1198
  // Not clamped to the items: an input set in the same task as this event has not reached the
1178
1199
  // list yet, and the window clamps when it renders.
1200
+ this.trackSpeed(content, event.nativeEvent?.timestamp);
1179
1201
  const visible = this.indexAt(content);
1180
1202
  if (visible !== this.visible())
1181
1203
  this.moveTo(visible);
1182
1204
  this.lastOffset = content;
1183
1205
  this.anchorAt(visible, content);
1184
- // A pinned row follows the scroll continuously, so with sticky rows the offset has to be a
1185
- // signal - and only then. Without them this stays a field, and a fling that moves no row in
1186
- // or out of the window costs no change detection at all.
1187
- if (this.pinning())
1188
- this.offset.set(content);
1189
- if (this.nativeSticky && this.pinning())
1190
- this.settleAfterPause(content);
1206
+ this.sticky.scrolled(content, along);
1191
1207
  this.checkEnd(along);
1192
1208
  this.announceViewable(content);
1193
1209
  }
1210
+ /**
1211
+ * Points the window reaches past the viewport for the scroll's speed, positive toward the end,
1212
+ * in steps of a quarter viewport: written only when it moves a step, so a fling costs a pass
1213
+ * for it every few frames rather than on every scroll event.
1214
+ */
1215
+ ahead = signal(0, /* @ts-ignore */
1216
+ ...(ngDevMode ? [{ debugName: "ahead" }] : /* istanbul ignore next */ []));
1217
+ /** The speed's lead before rounding to a step, eased from one event to the next. */
1218
+ eased = 0;
1219
+ /** The offset of the last scroll event, and when it arrived. */
1220
+ lastScroll = { offset: 0, at: -Infinity };
1221
+ /** Lets go of the reach once scroll events stop, which is all a scroll that stops sends. */
1222
+ speedTimer;
1223
+ /**
1224
+ * Follow the scroll's speed, from each scroll event's offset and the time native sent it, in
1225
+ * milliseconds, which iOS and Android both give. Not the time it reached JavaScript: a thread
1226
+ * that fell behind gets a fling's events in a burst, which would read as no time at all between
1227
+ * them. Where native gives no time, as on the web, the time it arrived.
1228
+ */
1229
+ trackSpeed(offset, sent) {
1230
+ const ms = this.velocityLead();
1231
+ const now = typeof sent === 'number' && Number.isFinite(sent) ? sent : performance.now();
1232
+ const elapsed = now - this.lastScroll.at;
1233
+ const moved = offset - this.lastScroll.offset;
1234
+ this.lastScroll = { offset, at: now };
1235
+ const viewport = this.viewport();
1236
+ // A pause, or the first event of a scroll, starts the speed over.
1237
+ if (!ms || !viewport || elapsed <= 0 || elapsed > PAUSE_MS) {
1238
+ this.eased = 0;
1239
+ }
1240
+ else {
1241
+ const reach = 3 * viewport;
1242
+ const clamp = (value) => Math.max(-reach, Math.min(reach, value));
1243
+ // Halfway to the new speed, so one late event does not throw the window around.
1244
+ this.eased = clamp((this.eased + clamp((moved / elapsed) * ms)) / 2);
1245
+ }
1246
+ const step = viewport / 4;
1247
+ const ahead = step ? Math.round(this.eased / step) * step : 0;
1248
+ this.ahead.set(ahead);
1249
+ clearTimeout(this.speedTimer);
1250
+ if (ahead)
1251
+ this.speedTimer = setTimeout(() => this.stopSpeed(), PAUSE_MS);
1252
+ }
1253
+ /** Start the speed over: a pause, or a jump, which is no fling. */
1254
+ stopSpeed() {
1255
+ clearTimeout(this.speedTimer);
1256
+ this.lastScroll = { offset: 0, at: -Infinity };
1257
+ this.eased = 0;
1258
+ this.ahead.set(0);
1259
+ }
1194
1260
  /** The most viewports rendered ahead of the scroll direction and behind it. */
1195
1261
  fillCaps() {
1196
1262
  const extra = Math.max(0, Math.floor(this.windowSize()) - 1);
@@ -1212,6 +1278,8 @@ export class VirtualList extends ScrollViewProps {
1212
1278
  const span = this.span();
1213
1279
  if (span && (index < span.first || index >= span.last))
1214
1280
  this.fill.set({ before: 0, after: 0 });
1281
+ // Nor is the scroll that reports it a fling: its speed starts over from where it lands.
1282
+ this.stopSpeed();
1215
1283
  }
1216
1284
  /**
1217
1285
  * Follow a change of scroll direction: the rows filled behind are now ahead, and those ahead are
@@ -1247,11 +1315,6 @@ export class VirtualList extends ScrollViewProps {
1247
1315
  return;
1248
1316
  this.fillTimer = setTimeout(() => this.fill.set({ ...reach, [side]: reach[side] + 1 }), FILL_BATCH_MS);
1249
1317
  }
1250
- /** A pinned row's translate, settled once scrolling pauses: see `STICKY_SETTLE_MS`. */
1251
- settleAfterPause(content) {
1252
- clearTimeout(this.settleTimer);
1253
- this.settleTimer = setTimeout(() => this.settled.set(content), STICKY_SETTLE_MS);
1254
- }
1255
1318
  onLayout(event) {
1256
1319
  const layout = event.nativeEvent?.layout;
1257
1320
  this.viewport.set((this.horizontal() ? layout?.width : layout?.height) ?? 0);
@@ -1285,19 +1348,42 @@ export class VirtualList extends ScrollViewProps {
1285
1348
  onContentSize(event) {
1286
1349
  const size = event.nativeEvent;
1287
1350
  this.contentSize = (this.horizontal() ? size?.width : size?.height) ?? 0;
1288
- this.contentSizeFor = this.extent();
1351
+ this.contentSizeFor = this.headerHeight() + this.extent();
1289
1352
  this.checkEnd(this.headerHeight() + this.lastOffset);
1290
1353
  }
1354
+ /** The scroll view's content along the axis, header and all. */
1355
+ contentExtent() {
1356
+ // Native's size is for the rows it last laid out; until it reports for these, their own extent.
1357
+ const own = this.headerHeight() + this.extent();
1358
+ return this.contentSizeFor === own ? this.contentSize : own;
1359
+ }
1360
+ /** The user took the scroll over: native's own events move the rows from here. */
1361
+ onDragBegin() {
1362
+ this.sticky.dragged();
1363
+ }
1364
+ /** A scroll came to rest: see `StickyRows.rested`. */
1365
+ onScrollEnd() {
1366
+ this.sticky.rested();
1367
+ }
1368
+ /**
1369
+ * How far toward `offset` the content lets native scroll. Android stops a scroll at its end and
1370
+ * says nothing of it; iOS goes past, and its scroll end event says where it came to rest.
1371
+ */
1372
+ reachable(offset) {
1373
+ const viewport = this.viewport();
1374
+ const total = this.contentExtent();
1375
+ // Past the content by the inset after it, where the scroll view lets it go.
1376
+ const inset = this.contentInset();
1377
+ const after = (this.horizontal() ? inset?.right : inset?.bottom) ?? 0;
1378
+ const end = viewport > 0 ? Math.max(0, total - viewport + after) : total;
1379
+ return Math.min(Math.max(0, offset), end);
1380
+ }
1291
1381
  checkEnd(y) {
1292
1382
  const count = this.items().length;
1293
1383
  const viewport = this.viewport();
1294
1384
  if (!count || !viewport)
1295
1385
  return;
1296
- // Native's size is for the rows it last laid out; until it reports for these, their own extent.
1297
- const extent = this.extent();
1298
- const reported = this.contentSizeFor === extent ? this.contentSize : 0;
1299
- const total = reported || this.headerHeight() + extent;
1300
- const distanceFromEnd = total - (y + viewport);
1386
+ const distanceFromEnd = this.contentExtent() - (y + viewport);
1301
1387
  // Away from the end again re-arms it, as React Native does, so a load that failed is retried
1302
1388
  // the next time the user comes back down.
1303
1389
  if (distanceFromEnd > this.endReachedThreshold() * viewport) {
@@ -1310,7 +1396,7 @@ export class VirtualList extends ScrollViewProps {
1310
1396
  this.endReached.emit({ distanceFromEnd });
1311
1397
  }
1312
1398
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: VirtualList, deps: [], target: i0.ɵɵFactoryTarget.Component });
1313
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.2.0", type: VirtualList, isStandalone: true, selector: "virtual-list", inputs: { items: { classPropertyName: "items", publicName: "items", isSignal: true, isRequired: true, transformFunction: null }, itemHeight: { classPropertyName: "itemHeight", publicName: "itemHeight", isSignal: true, isRequired: false, transformFunction: null }, estimatedItemHeight: { classPropertyName: "estimatedItemHeight", publicName: "estimatedItemHeight", isSignal: true, isRequired: false, transformFunction: null }, contentPadding: { classPropertyName: "contentPadding", publicName: "contentPadding", isSignal: true, isRequired: false, transformFunction: null }, rowGap: { classPropertyName: "rowGap", publicName: "rowGap", isSignal: true, isRequired: false, transformFunction: null }, keyExtractor: { classPropertyName: "keyExtractor", publicName: "keyExtractor", isSignal: true, isRequired: false, transformFunction: null }, itemType: { classPropertyName: "itemType", publicName: "itemType", isSignal: true, isRequired: false, transformFunction: null }, maintainVisibleContentPosition: { classPropertyName: "maintainVisibleContentPosition", publicName: "maintainVisibleContentPosition", isSignal: true, isRequired: false, transformFunction: null }, overscan: { classPropertyName: "overscan", publicName: "overscan", isSignal: true, isRequired: false, transformFunction: null }, windowSize: { classPropertyName: "windowSize", publicName: "windowSize", isSignal: true, isRequired: false, transformFunction: null }, endReachedThreshold: { classPropertyName: "endReachedThreshold", publicName: "endReachedThreshold", isSignal: true, isRequired: false, transformFunction: null }, horizontal: { classPropertyName: "horizontal", publicName: "horizontal", isSignal: true, isRequired: false, transformFunction: null }, inverted: { classPropertyName: "inverted", publicName: "inverted", isSignal: true, isRequired: false, transformFunction: null }, stickyIndices: { classPropertyName: "stickyIndices", publicName: "stickyIndices", isSignal: true, isRequired: false, transformFunction: null }, stickyHeader: { classPropertyName: "stickyHeader", publicName: "stickyHeader", isSignal: true, isRequired: false, transformFunction: null }, keyboardShouldPersistTaps: { classPropertyName: "keyboardShouldPersistTaps", publicName: "keyboardShouldPersistTaps", isSignal: true, isRequired: false, transformFunction: null }, itemVisiblePercentThreshold: { classPropertyName: "itemVisiblePercentThreshold", publicName: "itemVisiblePercentThreshold", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { endReached: "endReached", viewableItemsChanged: "viewableItemsChanged" }, host: { listeners: { "scroll": "onScroll($event)", "layout": "onLayout($event)", "contentSizeChange": "onContentSize($event)" }, properties: { "flexDirection": "horizontal() ? 'row' : 'column'", "horizontal": "horizontal()", "nestedScrollEnabled": "nestedScroll()", "transform": "flip()", "scrollEventThrottle": "scrollEventThrottle()" } }, queries: [{ propertyName: "separator", first: true, predicate: VirtualListSeparator, descendants: true, isSignal: true }, { propertyName: "refreshControl", first: true, predicate: RefreshControl, descendants: true, isSignal: true }], viewQueries: [{ propertyName: "canvasView", first: true, predicate: ["rows"], descendants: true, read: ElementRef, isSignal: true }], exportAs: ["virtualList"], usesInheritance: true, ngImport: i0, template: `
1399
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.2.0", type: VirtualList, isStandalone: true, selector: "virtual-list", inputs: { items: { classPropertyName: "items", publicName: "items", isSignal: true, isRequired: true, transformFunction: null }, itemHeight: { classPropertyName: "itemHeight", publicName: "itemHeight", isSignal: true, isRequired: false, transformFunction: null }, estimatedItemHeight: { classPropertyName: "estimatedItemHeight", publicName: "estimatedItemHeight", isSignal: true, isRequired: false, transformFunction: null }, contentPadding: { classPropertyName: "contentPadding", publicName: "contentPadding", isSignal: true, isRequired: false, transformFunction: null }, rowGap: { classPropertyName: "rowGap", publicName: "rowGap", isSignal: true, isRequired: false, transformFunction: null }, keyExtractor: { classPropertyName: "keyExtractor", publicName: "keyExtractor", isSignal: true, isRequired: false, transformFunction: null }, itemType: { classPropertyName: "itemType", publicName: "itemType", isSignal: true, isRequired: false, transformFunction: null }, maintainVisibleContentPosition: { classPropertyName: "maintainVisibleContentPosition", publicName: "maintainVisibleContentPosition", isSignal: true, isRequired: false, transformFunction: null }, overscan: { classPropertyName: "overscan", publicName: "overscan", isSignal: true, isRequired: false, transformFunction: null }, windowSize: { classPropertyName: "windowSize", publicName: "windowSize", isSignal: true, isRequired: false, transformFunction: null }, velocityLead: { classPropertyName: "velocityLead", publicName: "velocityLead", isSignal: true, isRequired: false, transformFunction: null }, endReachedThreshold: { classPropertyName: "endReachedThreshold", publicName: "endReachedThreshold", isSignal: true, isRequired: false, transformFunction: null }, horizontal: { classPropertyName: "horizontal", publicName: "horizontal", isSignal: true, isRequired: false, transformFunction: null }, inverted: { classPropertyName: "inverted", publicName: "inverted", isSignal: true, isRequired: false, transformFunction: null }, stickyIndices: { classPropertyName: "stickyIndices", publicName: "stickyIndices", isSignal: true, isRequired: false, transformFunction: null }, stickyHeader: { classPropertyName: "stickyHeader", publicName: "stickyHeader", isSignal: true, isRequired: false, transformFunction: null }, keyboardShouldPersistTaps: { classPropertyName: "keyboardShouldPersistTaps", publicName: "keyboardShouldPersistTaps", isSignal: true, isRequired: false, transformFunction: null }, itemVisiblePercentThreshold: { classPropertyName: "itemVisiblePercentThreshold", publicName: "itemVisiblePercentThreshold", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { endReached: "endReached", viewableItemsChanged: "viewableItemsChanged" }, host: { listeners: { "scrollBeginDrag": "onDragBegin()", "momentumScrollEnd": "onScrollEnd()", "layout": "onLayout($event)", "contentSizeChange": "onContentSize($event)" }, properties: { "flexDirection": "horizontal() ? 'row' : 'column'", "horizontal": "horizontal()", "nestedScrollEnabled": "nestedScroll()", "transform": "flip()", "scrollEventThrottle": "scrollEventThrottle()" } }, queries: [{ propertyName: "separator", first: true, predicate: VirtualListSeparator, descendants: true, isSignal: true }, { propertyName: "refreshControl", first: true, predicate: RefreshControl, descendants: true, isSignal: true }], viewQueries: [{ propertyName: "canvasView", first: true, predicate: ["rows"], descendants: true, read: ElementRef, isSignal: true }], exportAs: ["virtualList"], usesInheritance: true, ngImport: i0, template: `
1314
1400
  <ng-content select="refresh-control" />
1315
1401
  <view [style]="content()" collapsable="false">
1316
1402
  <view [style]="headerStyle()" (layout)="onHeaderLayout($event)"
@@ -1384,12 +1470,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImpor
1384
1470
  // where it would have ended up.
1385
1471
  '[transform]': 'flip()',
1386
1472
  '[scrollEventThrottle]': 'scrollEventThrottle()',
1387
- '(scroll)': 'onScroll($event)',
1473
+ '(scrollBeginDrag)': 'onDragBegin()',
1474
+ '(momentumScrollEnd)': 'onScrollEnd()',
1388
1475
  '(layout)': 'onLayout($event)',
1389
1476
  '(contentSizeChange)': 'onContentSize($event)',
1390
1477
  },
1391
1478
  }]
1392
- }], ctorParameters: () => [], propDecorators: { items: [{ type: i0.Input, args: [{ isSignal: true, alias: "items", required: true }] }], itemHeight: [{ type: i0.Input, args: [{ isSignal: true, alias: "itemHeight", required: false }] }], estimatedItemHeight: [{ type: i0.Input, args: [{ isSignal: true, alias: "estimatedItemHeight", required: false }] }], contentPadding: [{ type: i0.Input, args: [{ isSignal: true, alias: "contentPadding", required: false }] }], rowGap: [{ type: i0.Input, args: [{ isSignal: true, alias: "rowGap", required: false }] }], keyExtractor: [{ type: i0.Input, args: [{ isSignal: true, alias: "keyExtractor", required: false }] }], itemType: [{ type: i0.Input, args: [{ isSignal: true, alias: "itemType", required: false }] }], maintainVisibleContentPosition: [{ type: i0.Input, args: [{ isSignal: true, alias: "maintainVisibleContentPosition", required: false }] }], overscan: [{ type: i0.Input, args: [{ isSignal: true, alias: "overscan", required: false }] }], windowSize: [{ type: i0.Input, args: [{ isSignal: true, alias: "windowSize", required: false }] }], endReachedThreshold: [{ type: i0.Input, args: [{ isSignal: true, alias: "endReachedThreshold", required: false }] }], horizontal: [{ type: i0.Input, args: [{ isSignal: true, alias: "horizontal", required: false }] }], inverted: [{ type: i0.Input, args: [{ isSignal: true, alias: "inverted", required: false }] }], stickyIndices: [{ type: i0.Input, args: [{ isSignal: true, alias: "stickyIndices", required: false }] }], stickyHeader: [{ type: i0.Input, args: [{ isSignal: true, alias: "stickyHeader", required: false }] }], keyboardShouldPersistTaps: [{ type: i0.Input, args: [{ isSignal: true, alias: "keyboardShouldPersistTaps", required: false }] }], itemVisiblePercentThreshold: [{ type: i0.Input, args: [{ isSignal: true, alias: "itemVisiblePercentThreshold", required: false }] }], endReached: [{ type: i0.Output, args: ["endReached"] }], viewableItemsChanged: [{ type: i0.Output, args: ["viewableItemsChanged"] }], separator: [{ type: i0.ContentChild, args: [i0.forwardRef(() => VirtualListSeparator), { isSignal: true }] }], refreshControl: [{ type: i0.ContentChild, args: [i0.forwardRef(() => RefreshControl), { isSignal: true }] }], canvasView: [{ type: i0.ViewChild, args: ['rows', { ...{ read: ElementRef }, isSignal: true }] }] } });
1479
+ }], ctorParameters: () => [], propDecorators: { items: [{ type: i0.Input, args: [{ isSignal: true, alias: "items", required: true }] }], itemHeight: [{ type: i0.Input, args: [{ isSignal: true, alias: "itemHeight", required: false }] }], estimatedItemHeight: [{ type: i0.Input, args: [{ isSignal: true, alias: "estimatedItemHeight", required: false }] }], contentPadding: [{ type: i0.Input, args: [{ isSignal: true, alias: "contentPadding", required: false }] }], rowGap: [{ type: i0.Input, args: [{ isSignal: true, alias: "rowGap", required: false }] }], keyExtractor: [{ type: i0.Input, args: [{ isSignal: true, alias: "keyExtractor", required: false }] }], itemType: [{ type: i0.Input, args: [{ isSignal: true, alias: "itemType", required: false }] }], maintainVisibleContentPosition: [{ type: i0.Input, args: [{ isSignal: true, alias: "maintainVisibleContentPosition", required: false }] }], overscan: [{ type: i0.Input, args: [{ isSignal: true, alias: "overscan", required: false }] }], windowSize: [{ type: i0.Input, args: [{ isSignal: true, alias: "windowSize", required: false }] }], velocityLead: [{ type: i0.Input, args: [{ isSignal: true, alias: "velocityLead", required: false }] }], endReachedThreshold: [{ type: i0.Input, args: [{ isSignal: true, alias: "endReachedThreshold", required: false }] }], horizontal: [{ type: i0.Input, args: [{ isSignal: true, alias: "horizontal", required: false }] }], inverted: [{ type: i0.Input, args: [{ isSignal: true, alias: "inverted", required: false }] }], stickyIndices: [{ type: i0.Input, args: [{ isSignal: true, alias: "stickyIndices", required: false }] }], stickyHeader: [{ type: i0.Input, args: [{ isSignal: true, alias: "stickyHeader", required: false }] }], keyboardShouldPersistTaps: [{ type: i0.Input, args: [{ isSignal: true, alias: "keyboardShouldPersistTaps", required: false }] }], itemVisiblePercentThreshold: [{ type: i0.Input, args: [{ isSignal: true, alias: "itemVisiblePercentThreshold", required: false }] }], endReached: [{ type: i0.Output, args: ["endReached"] }], viewableItemsChanged: [{ type: i0.Output, args: ["viewableItemsChanged"] }], separator: [{ type: i0.ContentChild, args: [i0.forwardRef(() => VirtualListSeparator), { isSignal: true }] }], refreshControl: [{ type: i0.ContentChild, args: [i0.forwardRef(() => RefreshControl), { isSignal: true }] }], canvasView: [{ type: i0.ViewChild, args: ['rows', { ...{ read: ElementRef }, isSignal: true }] }] } });
1393
1480
  /** Whether a cached slot style already has every one of these props. */
1394
1481
  function holds(style, props) {
1395
1482
  return Object.entries(props).every(([prop, value]) => style[prop] === value);