@ng-native/components 0.27.0 → 0.29.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/android/src/main/java/dev/ngnative/components/ColorSchemeModule.kt +116 -11
- package/android/src/main/java/dev/ngnative/components/ContextMenuPopup.kt +61 -19
- package/android/src/main/java/dev/ngnative/components/MenusModule.kt +22 -0
- package/android/src/main/java/dev/ngnative/components/Shortcut.kt +13 -4
- package/dist/context-menu.d.ts +14 -6
- package/dist/context-menu.js +30 -28
- package/dist/context-menu.js.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/menu.d.ts +17 -8
- package/dist/menu.js +22 -36
- package/dist/menu.js.map +1 -1
- package/dist/modal.d.ts +6 -2
- package/dist/modal.js.map +1 -1
- package/dist/native-button.d.ts +31 -2
- package/dist/native-button.js +104 -6
- package/dist/native-button.js.map +1 -1
- package/dist/press-menu.d.ts +60 -0
- package/dist/press-menu.js +116 -0
- package/dist/press-menu.js.map +1 -0
- package/dist/pressable.d.ts +3 -0
- package/dist/pressable.js +7 -1
- package/dist/pressable.js.map +1 -1
- package/dist/reanimated.js +27 -3
- package/dist/reanimated.js.map +1 -1
- package/dist/scroll-view.d.ts +3 -1
- package/dist/scroll-view.js +7 -2
- package/dist/scroll-view.js.map +1 -1
- package/dist/settled-updates.d.ts +55 -0
- package/dist/settled-updates.js +77 -0
- package/dist/settled-updates.js.map +1 -0
- package/dist/sidebar-item.d.ts +18 -3
- package/dist/sidebar-item.js +29 -3
- package/dist/sidebar-item.js.map +1 -1
- package/dist/sidebar.js +4 -3
- package/dist/sidebar.js.map +1 -1
- package/dist/split-view.d.ts +23 -2
- package/dist/split-view.js +32 -5
- package/dist/split-view.js.map +1 -1
- package/dist/stand-ins/reanimated.d.ts +5 -0
- package/dist/stand-ins/reanimated.js +7 -0
- package/dist/stand-ins/reanimated.js.map +1 -1
- package/dist/sticky-headers.d.ts +19 -0
- package/dist/sticky-headers.js +67 -10
- package/dist/sticky-headers.js.map +1 -1
- package/dist/sticky-rows.d.ts +123 -26
- package/dist/sticky-rows.js +285 -71
- package/dist/sticky-rows.js.map +1 -1
- package/dist/svg-icon.d.ts +23 -0
- package/dist/svg-icon.js +53 -0
- package/dist/svg-icon.js.map +1 -0
- package/dist/tray-icon.d.ts +7 -1
- package/dist/tray-icon.js +15 -3
- package/dist/tray-icon.js.map +1 -1
- package/dist/virtual-list-sticky-level.d.ts +33 -0
- package/dist/virtual-list-sticky-level.js +58 -0
- package/dist/virtual-list-sticky-level.js.map +1 -0
- package/dist/virtual-list-sticky.d.ts +19 -0
- package/dist/virtual-list-sticky.js +13 -0
- package/dist/virtual-list-sticky.js.map +1 -0
- package/dist/virtual-list.d.ts +29 -7
- package/dist/virtual-list.js +127 -59
- package/dist/virtual-list.js.map +1 -1
- package/dist/worklet-style.d.ts +11 -0
- package/dist/worklet-style.js +15 -1
- package/dist/worklet-style.js.map +1 -1
- package/dist/worklets.d.ts +5 -1
- package/dist/worklets.js.map +1 -1
- package/dist/written-props.js +3 -0
- package/dist/written-props.js.map +1 -1
- package/ios/NgNativeButtonComponentView.mm +8 -4
- package/ios/NgNativeButtonMetrics.h +9 -2
- package/ios/NgNativeButtonMetrics.mm +33 -4
- package/ios/NgNativeButtonShadowNode.h +2 -0
- package/ios/NgNativeButtonShadowNode.mm +5 -1
- package/ios/NgNativeMenus.mm +42 -2
- package/ios/NgNativePressMenu.h +28 -0
- package/ios/NgNativePressMenu.mm +45 -0
- package/package.json +3 -3
package/dist/virtual-list.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Component, DestroyRef, Directive, ElementRef, TemplateRef, afterEveryRender, booleanAttribute, computed, contentChild, effect, inject, input, linkedSignal, output, signal, untracked, viewChild, } from '@angular/core';
|
|
2
2
|
import { nativePlatform, } from '@ng-native/fabric';
|
|
3
|
+
import { IN_FORM_SHEET } from '@ng-native/device';
|
|
3
4
|
import { HeightIndex } from "./height-index.js";
|
|
4
5
|
import { dismissKeyboardOnTap } from "./keyboard-taps.js";
|
|
5
6
|
import { RefreshControl } from "./refresh-control.js";
|
|
@@ -8,6 +9,7 @@ import { TemplateSlot } from "./template-slot.js";
|
|
|
8
9
|
import { ZeroSizeWarning, checksZeroSize, written } from "./zero-size-warning.js";
|
|
9
10
|
import { View } from "./view.js";
|
|
10
11
|
import { VIRTUAL_LIST_LAYOUT } from "./virtual-list-layout.js";
|
|
12
|
+
import { VIRTUAL_LIST_STICKY } from "./virtual-list-sticky.js";
|
|
11
13
|
import { ScrollViewProps } from "./scroll-view-props.js";
|
|
12
14
|
import { numberOr } from "./transforms.js";
|
|
13
15
|
import * as i0 from "@angular/core";
|
|
@@ -102,7 +104,8 @@ const PAUSE_MS = 200;
|
|
|
102
104
|
* the first sticky row pushes it off as RN's sticky headers push each other. Neither is native:
|
|
103
105
|
* RN's `ScrollView.js` translates a sticky child against the scroll offset in JavaScript, and a
|
|
104
106
|
* row here follows the offset the same way while it is the current one - by its `top` when
|
|
105
|
-
* absolutely positioned, by a transform when in flow.
|
|
107
|
+
* absolutely positioned, by a transform when in flow. `[virtualListStickyLevel]` on the list pins
|
|
108
|
+
* rows at more than one level, each under the rows of the levels further out.
|
|
106
109
|
*
|
|
107
110
|
* What is on screen stays on screen when a measured row above it turns out taller or shorter than
|
|
108
111
|
* its estimate: the offset is corrected by the difference. `maintainVisibleContentPosition` does
|
|
@@ -225,8 +228,9 @@ export class VirtualList extends ScrollViewProps {
|
|
|
225
228
|
...(ngDevMode ? [{ debugName: "separator" }] : /* istanbul ignore next */ []));
|
|
226
229
|
refreshControl = contentChild(RefreshControl, /* @ts-ignore */
|
|
227
230
|
...(ngDevMode ? [{ debugName: "refreshControl" }] : /* istanbul ignore next */ []));
|
|
228
|
-
|
|
229
|
-
|
|
231
|
+
inSheet = inject(IN_FORM_SHEET);
|
|
232
|
+
/** See ScrollView: inside Android's swipe layout or a form sheet the list must see a drag first. */
|
|
233
|
+
nestedScroll = computed(() => nativePlatform() === 'android' && (this.inSheet || this.refreshControl()) ? true : undefined, /* @ts-ignore */
|
|
230
234
|
...(ngDevMode ? [{ debugName: "nestedScroll" }] : /* istanbul ignore next */ []));
|
|
231
235
|
/** Viewports filled past the overscan, before and after the visible rows in index order. */
|
|
232
236
|
fill = signal({ before: 0, after: 0 }, /* @ts-ignore */
|
|
@@ -247,9 +251,12 @@ export class VirtualList extends ScrollViewProps {
|
|
|
247
251
|
...(ngDevMode ? [{ debugName: "reach" }] : /* istanbul ignore next */ []));
|
|
248
252
|
fillTimer;
|
|
249
253
|
canvasView = viewChild.required('rows', { ...(ngDevMode ? { debugName: "canvasView" } : /* istanbul ignore next */ {}), read: ElementRef });
|
|
254
|
+
headerView = viewChild.required('header', { ...(ngDevMode ? { debugName: "headerView" } : /* istanbul ignore next */ {}), read: ElementRef });
|
|
250
255
|
/** The sticky rows and header: see `StickyRows`. */
|
|
251
256
|
sticky = new StickyRows(this.engine, this.node, {
|
|
252
257
|
indices: this.stickyIndices,
|
|
258
|
+
levels: inject(VIRTUAL_LIST_STICKY, { self: true, optional: true }),
|
|
259
|
+
items: this.items,
|
|
253
260
|
header: this.stickyHeader,
|
|
254
261
|
headerHeight: this.headerHeight,
|
|
255
262
|
horizontal: () => this.horizontal(),
|
|
@@ -301,7 +308,7 @@ export class VirtualList extends ScrollViewProps {
|
|
|
301
308
|
if (columns === 1)
|
|
302
309
|
return null;
|
|
303
310
|
const count = this.items().length;
|
|
304
|
-
const sticky = this.sticky.
|
|
311
|
+
const sticky = this.sticky.rows();
|
|
305
312
|
const of = new Int32Array(count);
|
|
306
313
|
const starts = [];
|
|
307
314
|
let column = columns;
|
|
@@ -329,7 +336,7 @@ export class VirtualList extends ScrollViewProps {
|
|
|
329
336
|
/** An item's insets across the axis: its column's, or the whole width's. */
|
|
330
337
|
acrossOf(index) {
|
|
331
338
|
const lines = this.lines();
|
|
332
|
-
if (!lines || this.sticky.
|
|
339
|
+
if (!lines || this.sticky.rows().has(index))
|
|
333
340
|
return this.across();
|
|
334
341
|
return this.columnAcross()[index - lines.starts[lines.of[index]]];
|
|
335
342
|
}
|
|
@@ -799,35 +806,71 @@ export class VirtualList extends ScrollViewProps {
|
|
|
799
806
|
*/
|
|
800
807
|
spacer = computed(() => {
|
|
801
808
|
const span = this.span();
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
if (span && pinned !== null && pinned < span.first) {
|
|
805
|
-
lead = this.sticky.native ? this.topOf(pinned) : lead - this.heightOf(pinned) - this.rowGap();
|
|
806
|
-
}
|
|
807
|
-
return this.horizontal() ? { width: Math.max(0, lead) } : { height: Math.max(0, lead) };
|
|
809
|
+
const lead = span ? Math.max(0, this.flowStart(span.first, this.rendersAhead())) : 0;
|
|
810
|
+
return this.horizontal() ? { width: lead } : { height: lead };
|
|
808
811
|
}, /* @ts-ignore */
|
|
809
812
|
...(ngDevMode ? [{ debugName: "spacer" }] : /* istanbul ignore next */ []));
|
|
810
|
-
/**
|
|
813
|
+
/**
|
|
814
|
+
* Where the first row rendered in flow starts: `first`'s place, less each row rendered ahead of
|
|
815
|
+
* it, or where native moves them, the first of those rows' own place. Less than nothing where a
|
|
816
|
+
* negative gap overlaps the rows not rendered, which the spacer cannot be: the first row takes
|
|
817
|
+
* the rest as a margin (`rowsFor`).
|
|
818
|
+
*/
|
|
819
|
+
flowStart(first, ahead) {
|
|
820
|
+
if (this.sticky.native && ahead.length > 0)
|
|
821
|
+
return this.topOf(ahead[0]);
|
|
822
|
+
let start = this.topOf(first);
|
|
823
|
+
for (const index of ahead)
|
|
824
|
+
start -= this.heightOf(index) + this.rowGap();
|
|
825
|
+
return start;
|
|
826
|
+
}
|
|
827
|
+
/**
|
|
828
|
+
* The rows rendered ahead of the window: the pinned rows it has left behind, and where native
|
|
829
|
+
* moves rows in flow, the row before each pinned row after the outermost. Flow places a row
|
|
830
|
+
* after the row before it, so with that row rendered too, a pinned row is at its own place
|
|
831
|
+
* with no margin of its own, and its props stay as they are as the window moves past it.
|
|
832
|
+
*/
|
|
833
|
+
rendersAhead = computed(() => {
|
|
834
|
+
const span = this.span();
|
|
835
|
+
if (!span)
|
|
836
|
+
return [];
|
|
837
|
+
const pinned = this.sticky.pinned();
|
|
838
|
+
const ahead = new Set(pinned.filter((index) => index < span.first));
|
|
839
|
+
if (this.sticky.native && this.measuring()) {
|
|
840
|
+
for (const index of pinned.slice(1)) {
|
|
841
|
+
if (index <= span.first && index - 1 < span.first)
|
|
842
|
+
ahead.add(index - 1);
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
return [...ahead].sort((a, b) => a - b);
|
|
846
|
+
}, { ...(ngDevMode ? { debugName: "rendersAhead" } : /* istanbul ignore next */ {}), equal: (a, b) => a.length === b.length && a.every((index, at) => index === b[at]) });
|
|
847
|
+
/** The rows from `first` up to `last`, and the rows ahead of them if there are any. */
|
|
811
848
|
rowsFor(items, first, last) {
|
|
812
849
|
const rows = [];
|
|
813
850
|
const pinned = this.sticky.pinned();
|
|
814
|
-
const
|
|
815
|
-
this.releaseRecycled(first, last,
|
|
816
|
-
//
|
|
851
|
+
const ahead = this.rendersAhead();
|
|
852
|
+
this.releaseRecycled(first, last, ahead);
|
|
853
|
+
// Where flow puts each row ahead of the window, where JavaScript moves the pinned ones.
|
|
854
|
+
const start = this.flowStart(first, ahead);
|
|
855
|
+
let at = start;
|
|
856
|
+
// A pinned row is on screen even when its own place in the list is not, which is the whole
|
|
817
857
|
// point of it, so it is rendered whether or not the window reaches that far.
|
|
818
|
-
|
|
819
|
-
const key = this.keyAt(
|
|
858
|
+
for (const index of ahead) {
|
|
859
|
+
const key = this.keyAt(index);
|
|
820
860
|
rows.push(this.hold({
|
|
821
|
-
index
|
|
822
|
-
slot: this.recycledSlot(key, items[
|
|
861
|
+
index,
|
|
862
|
+
slot: this.recycledSlot(key, items[index], index),
|
|
823
863
|
key,
|
|
824
|
-
item: items[
|
|
864
|
+
item: items[index],
|
|
825
865
|
style: this.sticky.native
|
|
826
|
-
?
|
|
866
|
+
? pinned.includes(index)
|
|
867
|
+
? this.sticky.style(index)
|
|
868
|
+
: this.flowStyle()
|
|
827
869
|
: this.measuring()
|
|
828
|
-
? this.sticky.flowStyle(
|
|
829
|
-
: this.
|
|
870
|
+
? this.sticky.flowStyle(index, at)
|
|
871
|
+
: this.sticky.slotStyle(index),
|
|
830
872
|
}));
|
|
873
|
+
at += this.heightOf(index) + this.rowGap();
|
|
831
874
|
}
|
|
832
875
|
for (let index = first; index < last; index++) {
|
|
833
876
|
const key = this.keyAt(index);
|
|
@@ -836,34 +879,50 @@ export class VirtualList extends ScrollViewProps {
|
|
|
836
879
|
slot: this.recycledSlot(key, items[index], index),
|
|
837
880
|
key,
|
|
838
881
|
item: items[index],
|
|
839
|
-
style: this.styleFor(index, index
|
|
882
|
+
style: this.styleFor(index, pinned.includes(index)),
|
|
840
883
|
}));
|
|
841
884
|
}
|
|
842
|
-
if (
|
|
843
|
-
this.
|
|
885
|
+
if (ahead.length > 0 && this.sticky.native && this.measuring()) {
|
|
886
|
+
this.placeAhead(rows, ahead.length + 1, pinned);
|
|
887
|
+
}
|
|
888
|
+
if (start < 0)
|
|
889
|
+
this.startBefore(rows, start);
|
|
844
890
|
return rows;
|
|
845
891
|
}
|
|
892
|
+
/** Start the first row in flow at `start`, below zero, where the spacer cannot reach. */
|
|
893
|
+
startBefore(rows, start) {
|
|
894
|
+
const [row] = rows;
|
|
895
|
+
if (!row || !this.measuring())
|
|
896
|
+
return;
|
|
897
|
+
const margin = this.horizontal() ? 'marginLeft' : 'marginTop';
|
|
898
|
+
rows[0] = this.hold({ ...row, style: { ...row.style, [margin]: start } });
|
|
899
|
+
}
|
|
846
900
|
/**
|
|
847
|
-
* A pinned row native moves stays at its own place, so the rows
|
|
848
|
-
* made up
|
|
849
|
-
*
|
|
901
|
+
* A pinned row native moves stays at its own place, so the rows that are not rendered between
|
|
902
|
+
* it and the next are made up by a margin on the next row that is not pinned, up to the
|
|
903
|
+
* window's first, a negative one where a negative gap overlaps them: new props on a view native
|
|
904
|
+
* is moving put its transform back for a frame.
|
|
850
905
|
*/
|
|
851
|
-
|
|
852
|
-
const lead = rows[1];
|
|
853
|
-
// The pinned row's own gap already follows it in flow.
|
|
854
|
-
const between = this.topOf(first) - this.topOf(pinned) - this.heightOf(pinned) - this.rowGap();
|
|
855
|
-
if (!lead || between <= 0)
|
|
856
|
-
return;
|
|
906
|
+
placeAhead(rows, count, pinned) {
|
|
857
907
|
const margin = this.horizontal() ? 'marginLeft' : 'marginTop';
|
|
858
|
-
|
|
908
|
+
let end = this.topOf(rows[0].index);
|
|
909
|
+
for (let at = 0; at < Math.min(count, rows.length); at++) {
|
|
910
|
+
const row = rows[at];
|
|
911
|
+
const start = this.topOf(row.index);
|
|
912
|
+
if (start !== end && !pinned.includes(row.index)) {
|
|
913
|
+
rows[at] = this.hold({ ...row, style: { ...row.style, [margin]: start - end } });
|
|
914
|
+
}
|
|
915
|
+
// A row's own gap already follows it in flow.
|
|
916
|
+
end = start + this.heightOf(row.index) + this.rowGap();
|
|
917
|
+
}
|
|
859
918
|
}
|
|
860
919
|
styleFor(index, pinned) {
|
|
861
|
-
if (this.sticky.native && this.sticky.
|
|
920
|
+
if (this.sticky.native && this.sticky.rows().has(index))
|
|
862
921
|
return this.sticky.style(index);
|
|
863
922
|
if (this.measuring()) {
|
|
864
|
-
return pinned ? this.sticky.flowStyle(this.topOf(index)) : this.flowStyle();
|
|
923
|
+
return pinned ? this.sticky.flowStyle(index, this.topOf(index)) : this.flowStyle();
|
|
865
924
|
}
|
|
866
|
-
return pinned ? this.slotStyle(index
|
|
925
|
+
return pinned ? this.sticky.slotStyle(index) : this.slotStyle(index);
|
|
867
926
|
}
|
|
868
927
|
/**
|
|
869
928
|
* Hand each rendered sticky row's view to native to move. The rows' views are the canvas's
|
|
@@ -874,7 +933,7 @@ export class VirtualList extends ScrollViewProps {
|
|
|
874
933
|
const views = () => this.canvasView().nativeElement.childList
|
|
875
934
|
.filter((child) => child.nodeKind === 'element')
|
|
876
935
|
.slice(this.measuring() ? 1 : 0);
|
|
877
|
-
this.sticky.drive(() => this.window(), views);
|
|
936
|
+
this.sticky.drive(() => this.window(), views, () => this.headerView().nativeElement);
|
|
878
937
|
}
|
|
879
938
|
/** Which recycling slot each rendered item holds, by key: its type, and the row it last drew. */
|
|
880
939
|
recycled = new Map();
|
|
@@ -900,8 +959,8 @@ export class VirtualList extends ScrollViewProps {
|
|
|
900
959
|
const keep = new Set();
|
|
901
960
|
for (let index = first; index < last; index++)
|
|
902
961
|
keep.add(this.keyAt(index));
|
|
903
|
-
|
|
904
|
-
keep.add(this.keyAt(
|
|
962
|
+
for (const index of pinned)
|
|
963
|
+
keep.add(this.keyAt(index));
|
|
905
964
|
for (const [key, held] of this.recycled) {
|
|
906
965
|
if (keep.has(key))
|
|
907
966
|
continue;
|
|
@@ -930,7 +989,7 @@ export class VirtualList extends ScrollViewProps {
|
|
|
930
989
|
// A sticky row is a type of its own: native keeps the translate it moved one by, and a plain
|
|
931
990
|
// row taking its slot commits no transform to put it back. A row that stops or starts being
|
|
932
991
|
// sticky takes a new slot for the same reason.
|
|
933
|
-
const sticky = this.sticky.
|
|
992
|
+
const sticky = this.sticky.rows().has(index);
|
|
934
993
|
const held = this.recycled.get(key);
|
|
935
994
|
if (held && this.sticky.isType(held.type) === sticky)
|
|
936
995
|
return held.slot;
|
|
@@ -1161,8 +1220,8 @@ export class VirtualList extends ScrollViewProps {
|
|
|
1161
1220
|
this.jumpTo(this.items().length - 1);
|
|
1162
1221
|
this.engine.dispatchCommand(this.node, 'scrollToEnd', [options.animated ?? true]);
|
|
1163
1222
|
}
|
|
1164
|
-
slotStyle(index
|
|
1165
|
-
const start =
|
|
1223
|
+
slotStyle(index) {
|
|
1224
|
+
const start = this.topOf(index);
|
|
1166
1225
|
const size = this.heightOf(index);
|
|
1167
1226
|
const horizontal = this.horizontal();
|
|
1168
1227
|
const key = horizontal ? 'left' : 'top';
|
|
@@ -1173,15 +1232,12 @@ export class VirtualList extends ScrollViewProps {
|
|
|
1173
1232
|
// The flip is part of the comparison because turning the list over changes every row, and a
|
|
1174
1233
|
// cached slot would otherwise keep the orientation it was built with.
|
|
1175
1234
|
const placed = { ...across, [extent]: size, [key]: start, transform: flip };
|
|
1176
|
-
const stale = !style ||
|
|
1235
|
+
const stale = !style || !holds(style, placed);
|
|
1177
1236
|
if (stale) {
|
|
1178
1237
|
style = horizontal
|
|
1179
1238
|
? { position: 'absolute', ...across, left: start, width: size }
|
|
1180
1239
|
: { position: 'absolute', ...across, top: start, height: size };
|
|
1181
|
-
//
|
|
1182
|
-
// the inversion.
|
|
1183
|
-
if (pinnedAt !== undefined)
|
|
1184
|
-
style['zIndex'] = 1;
|
|
1240
|
+
// The transform is the row's half of the inversion.
|
|
1185
1241
|
if (flip)
|
|
1186
1242
|
style['transform'] = flip;
|
|
1187
1243
|
this.slots.set(index, style);
|
|
@@ -1198,14 +1254,18 @@ export class VirtualList extends ScrollViewProps {
|
|
|
1198
1254
|
// Not clamped to the items: an input set in the same task as this event has not reached the
|
|
1199
1255
|
// list yet, and the window clamps when it renders.
|
|
1200
1256
|
this.trackSpeed(content, event.nativeEvent?.timestamp);
|
|
1257
|
+
this.follow(content);
|
|
1258
|
+
this.sticky.scrolled(along);
|
|
1259
|
+
this.checkEnd(along);
|
|
1260
|
+
this.announceViewable(content);
|
|
1261
|
+
}
|
|
1262
|
+
/** Take the viewport's leading edge, in the rows' own space, as where the list is. */
|
|
1263
|
+
follow(content) {
|
|
1201
1264
|
const visible = this.indexAt(content);
|
|
1202
1265
|
if (visible !== this.visible())
|
|
1203
1266
|
this.moveTo(visible);
|
|
1204
1267
|
this.lastOffset = content;
|
|
1205
1268
|
this.anchorAt(visible, content);
|
|
1206
|
-
this.sticky.scrolled(content, along);
|
|
1207
|
-
this.checkEnd(along);
|
|
1208
|
-
this.announceViewable(content);
|
|
1209
1269
|
}
|
|
1210
1270
|
/**
|
|
1211
1271
|
* Points the window reaches past the viewport for the scroll's speed, positive toward the end,
|
|
@@ -1329,8 +1389,15 @@ export class VirtualList extends ScrollViewProps {
|
|
|
1329
1389
|
const height = (this.horizontal() ? layout?.width : layout?.height) ?? 0;
|
|
1330
1390
|
if (height === this.headerHeight())
|
|
1331
1391
|
return;
|
|
1392
|
+
const along = this.headerHeight() + this.lastOffset;
|
|
1332
1393
|
this.headerHeight.set(height);
|
|
1333
|
-
this.holdPastHeader()
|
|
1394
|
+
if (this.holdPastHeader())
|
|
1395
|
+
return;
|
|
1396
|
+
// Native keeps its offset and sends no scroll event, so the rows moved under the viewport by
|
|
1397
|
+
// the difference: the window, the end and what is viewable are taken again from there.
|
|
1398
|
+
this.follow(along - height);
|
|
1399
|
+
this.checkEnd(along);
|
|
1400
|
+
this.announceViewable(along - height);
|
|
1334
1401
|
}
|
|
1335
1402
|
/**
|
|
1336
1403
|
* The header grew or shrank - a typing indicator in a chat's, a banner in a feed's - and every
|
|
@@ -1342,8 +1409,9 @@ export class VirtualList extends ScrollViewProps {
|
|
|
1342
1409
|
holdPastHeader() {
|
|
1343
1410
|
const hold = this.maintainVisibleContentPosition();
|
|
1344
1411
|
if (!hold || this.lastOffset <= (hold.autoscrollToTopThreshold ?? 0))
|
|
1345
|
-
return;
|
|
1412
|
+
return false;
|
|
1346
1413
|
this.scrollToOffset({ offset: this.headerHeight() + this.lastOffset, animated: false });
|
|
1414
|
+
return true;
|
|
1347
1415
|
}
|
|
1348
1416
|
onContentSize(event) {
|
|
1349
1417
|
const size = event.nativeEvent;
|
|
@@ -1396,10 +1464,10 @@ export class VirtualList extends ScrollViewProps {
|
|
|
1396
1464
|
this.endReached.emit({ distanceFromEnd });
|
|
1397
1465
|
}
|
|
1398
1466
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: VirtualList, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
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: `
|
|
1467
|
+
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 }, { propertyName: "headerView", first: true, predicate: ["header"], descendants: true, read: ElementRef, isSignal: true }], exportAs: ["virtualList"], usesInheritance: true, ngImport: i0, template: `
|
|
1400
1468
|
<ng-content select="refresh-control" />
|
|
1401
1469
|
<view [style]="content()" collapsable="false">
|
|
1402
|
-
<view [style]="headerStyle()" (layout)="onHeaderLayout($event)"
|
|
1470
|
+
<view #header [style]="headerStyle()" (layout)="onHeaderLayout($event)"
|
|
1403
1471
|
><ng-content select="[listHeader]"
|
|
1404
1472
|
/></view>
|
|
1405
1473
|
<view #rows [style]="canvas()" collapsable="false">
|
|
@@ -1437,7 +1505,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImpor
|
|
|
1437
1505
|
template: `
|
|
1438
1506
|
<ng-content select="refresh-control" />
|
|
1439
1507
|
<view [style]="content()" collapsable="false">
|
|
1440
|
-
<view [style]="headerStyle()" (layout)="onHeaderLayout($event)"
|
|
1508
|
+
<view #header [style]="headerStyle()" (layout)="onHeaderLayout($event)"
|
|
1441
1509
|
><ng-content select="[listHeader]"
|
|
1442
1510
|
/></view>
|
|
1443
1511
|
<view #rows [style]="canvas()" collapsable="false">
|
|
@@ -1476,7 +1544,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImpor
|
|
|
1476
1544
|
'(contentSizeChange)': 'onContentSize($event)',
|
|
1477
1545
|
},
|
|
1478
1546
|
}]
|
|
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 }] }] } });
|
|
1547
|
+
}], 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 }] }], headerView: [{ type: i0.ViewChild, args: ['header', { ...{ read: ElementRef }, isSignal: true }] }] } });
|
|
1480
1548
|
/** Whether a cached slot style already has every one of these props. */
|
|
1481
1549
|
function holds(style, props) {
|
|
1482
1550
|
return Object.entries(props).every(([prop, value]) => style[prop] === value);
|