@ng-native/components 0.24.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.
- package/android/src/main/java/dev/ngnative/components/ColorSchemeModule.kt +97 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/reanimated-web.d.ts +1 -0
- package/dist/reanimated-web.js +1 -0
- package/dist/reanimated-web.js.map +1 -1
- package/dist/reanimated.d.ts +1 -0
- package/dist/reanimated.js +1 -0
- package/dist/reanimated.js.map +1 -1
- package/dist/release-on-destroy.d.ts +32 -0
- package/dist/release-on-destroy.js +45 -0
- package/dist/release-on-destroy.js.map +1 -0
- package/dist/section-list.d.ts +5 -1
- package/dist/section-list.js +11 -3
- package/dist/section-list.js.map +1 -1
- package/dist/sticky-rows.d.ts +142 -0
- package/dist/sticky-rows.js +274 -0
- package/dist/sticky-rows.js.map +1 -0
- package/dist/virtual-list-layout.d.ts +21 -0
- package/dist/virtual-list-layout.js +11 -0
- package/dist/virtual-list-layout.js.map +1 -0
- package/dist/virtual-list-num-columns.d.ts +47 -0
- package/dist/virtual-list-num-columns.js +97 -0
- package/dist/virtual-list-num-columns.js.map +1 -0
- package/dist/virtual-list.d.ts +111 -50
- package/dist/virtual-list.js +378 -197
- package/dist/virtual-list.js.map +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { type Signal } from '@angular/core';
|
|
2
|
+
import { type HostEngine, type HostNode, type StaticTransform } from '@ng-native/fabric';
|
|
3
|
+
/** What `StickyRows` needs of the list whose rows it pins. */
|
|
4
|
+
export interface StickyRowsList {
|
|
5
|
+
/** The sticky rows' indices, as `stickyIndices` gives them. */
|
|
6
|
+
readonly indices: Signal<readonly number[]>;
|
|
7
|
+
/** Whether the list header is pinned too, as `stickyHeader` says. */
|
|
8
|
+
readonly header: Signal<boolean>;
|
|
9
|
+
readonly headerHeight: Signal<number>;
|
|
10
|
+
horizontal(): boolean;
|
|
11
|
+
/** Rows size themselves and are laid out in flow. */
|
|
12
|
+
measuring(): boolean;
|
|
13
|
+
topOf(index: number): number;
|
|
14
|
+
heightOf(index: number): number;
|
|
15
|
+
/** An absolutely positioned row's style, at its own place. */
|
|
16
|
+
slotStyle(index: number): Record<string, unknown>;
|
|
17
|
+
/** What places a row in flow. */
|
|
18
|
+
flowSpacing(): Record<string, unknown>;
|
|
19
|
+
/** The list's flip, as transforms and as CSS text, when it is inverted. */
|
|
20
|
+
flip(): readonly StaticTransform[] | undefined;
|
|
21
|
+
flipText(): string | undefined;
|
|
22
|
+
}
|
|
23
|
+
/** A row as the list renders it, for what `StickyRows` reads of it. */
|
|
24
|
+
interface Row {
|
|
25
|
+
readonly index: number;
|
|
26
|
+
readonly parked?: boolean;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* `<virtual-list>`'s sticky rows: which one holds the leading edge, the style that pins it, the
|
|
30
|
+
* header's pinned style, and, where the host moves views by the scroll on the native side, what
|
|
31
|
+
* native is moving. The list's own share of `stickyIndices` and `stickyHeader`, as `StickyHeaders`
|
|
32
|
+
* is `<scroll-view>`'s.
|
|
33
|
+
*
|
|
34
|
+
* Pinning is not native: RN's `ScrollView.js` translates a sticky child against the scroll offset
|
|
35
|
+
* in JavaScript, and a row here follows the offset the same way while it is the current one, by
|
|
36
|
+
* its `top` when absolutely positioned and by a transform when in flow. Where native can move a
|
|
37
|
+
* view by the scroll, each sticky row instead stays at its own place in the list and native
|
|
38
|
+
* translates it on every frame the list scrolls, as RN's `ScrollViewStickyHeader` does; a
|
|
39
|
+
* translate committed from each scroll event lands a frame or more late, and on a fast fling the
|
|
40
|
+
* row shudders and comes away from the edge.
|
|
41
|
+
*/
|
|
42
|
+
export declare class StickyRows {
|
|
43
|
+
/** Whether native moves sticky rows. */
|
|
44
|
+
readonly native: boolean;
|
|
45
|
+
/** The leading edge of the viewport in content space, kept only while anything is pinned. */
|
|
46
|
+
private readonly leading;
|
|
47
|
+
readonly offset: Signal<number>;
|
|
48
|
+
private readonly engine;
|
|
49
|
+
private readonly node;
|
|
50
|
+
private readonly list;
|
|
51
|
+
/** The offset once scrolling pauses, which the settled translate of a native-moved row is from. */
|
|
52
|
+
private readonly settled;
|
|
53
|
+
private settleTimer;
|
|
54
|
+
/** What native is moving, by row view, with the transform kept beside the translate. */
|
|
55
|
+
private readonly drives;
|
|
56
|
+
/** The list scrolled itself, and native has not drawn its sticky rows there yet. */
|
|
57
|
+
private jumped;
|
|
58
|
+
/** Native has reported reaching the target, so this pass's drives are the last to need telling. */
|
|
59
|
+
private landed;
|
|
60
|
+
/** Where the list scrolled itself to, in the scroll view, which native reports with its event. */
|
|
61
|
+
private jumpedTo;
|
|
62
|
+
/** Whether that scroll is animated, so native is still at its start until it reports. */
|
|
63
|
+
private jumpAnimated;
|
|
64
|
+
/** Where native's latest event since the jump said the scroll view was, header and all. */
|
|
65
|
+
private reported;
|
|
66
|
+
/** Where native's latest event of all said it was, header and all. */
|
|
67
|
+
private nativeAt;
|
|
68
|
+
/**
|
|
69
|
+
* Scroll end events still to come, one for each jump that moved native, as iOS sends one. Kept
|
|
70
|
+
* across jumps: one that landed has its end still to come, and must not be taken for the next's.
|
|
71
|
+
*/
|
|
72
|
+
private ends;
|
|
73
|
+
/** The recycling type of a sticky row of each `itemType`: apart from plain rows of it. */
|
|
74
|
+
private readonly typeOfKind;
|
|
75
|
+
private readonly types;
|
|
76
|
+
constructor(engine: HostEngine, node: HostNode, list: StickyRowsList);
|
|
77
|
+
/** Whether the scroll offset is needed as a signal, which only pinning needs. */
|
|
78
|
+
private readonly pinning;
|
|
79
|
+
/** Each sticky row, and the one after it, which pushes it off. */
|
|
80
|
+
readonly next: Signal<Map<number, number>>;
|
|
81
|
+
/**
|
|
82
|
+
* The sticky row currently holding the leading edge: the last one at or before the offset.
|
|
83
|
+
* Null when the list has scrolled back above the first of them.
|
|
84
|
+
*/
|
|
85
|
+
readonly pinned: Signal<number | null>;
|
|
86
|
+
/**
|
|
87
|
+
* The header's translation while it is pinned: the scroll position, held back at zero by an
|
|
88
|
+
* overscroll and at the first sticky row, which pushes it off.
|
|
89
|
+
*/
|
|
90
|
+
readonly headerStyle: Signal<{
|
|
91
|
+
transform: string;
|
|
92
|
+
zIndex?: undefined;
|
|
93
|
+
} | {
|
|
94
|
+
zIndex: number;
|
|
95
|
+
transform: string;
|
|
96
|
+
} | {
|
|
97
|
+
zIndex: number;
|
|
98
|
+
transform?: undefined;
|
|
99
|
+
} | undefined>;
|
|
100
|
+
/** A pinned row in flow, moved from where flow put it to the leading edge by a transform. */
|
|
101
|
+
flowStyle(at: number): Record<string, unknown>;
|
|
102
|
+
/**
|
|
103
|
+
* A sticky row native moves: at its own place, with the translate native had reached when
|
|
104
|
+
* scrolling paused, so the props agree with what is on screen.
|
|
105
|
+
*/
|
|
106
|
+
style(index: number): Record<string, unknown>;
|
|
107
|
+
/**
|
|
108
|
+
* The recycling type of a row: a sticky row is a type of its own, since native keeps the
|
|
109
|
+
* translate it moved one by, and a plain row taking its slot commits no transform to put it
|
|
110
|
+
* back. Apart from that, `kind`, the row's `itemType`.
|
|
111
|
+
*/
|
|
112
|
+
recyclingType(index: number, kind: unknown): unknown;
|
|
113
|
+
/** Whether a recycling type is a sticky row's. */
|
|
114
|
+
isType(type: unknown): boolean;
|
|
115
|
+
/** The list scrolled, to `offset` in content space and `along` in the scroll view. */
|
|
116
|
+
scrolled(offset: number, along: number): void;
|
|
117
|
+
/** The list is scrolling itself, to `to` in the scroll view, where native has not drawn yet. */
|
|
118
|
+
jumping(to: number, animated: boolean): void;
|
|
119
|
+
/** The user took the scroll over: native's own events move the rows from here. */
|
|
120
|
+
dragged(): void;
|
|
121
|
+
/**
|
|
122
|
+
* A scroll came to rest. The last of the jumps on their way has landed, wherever it did: iOS
|
|
123
|
+
* does not stop a scroll at the end of the content, so it can rest past where the list said,
|
|
124
|
+
* and what moves it next (a tap on the status bar) is not a drag.
|
|
125
|
+
*/
|
|
126
|
+
rested(): void;
|
|
127
|
+
/**
|
|
128
|
+
* Hand each rendered sticky row's view to native to move, and let go of the rest. `views` are
|
|
129
|
+
* the rendered rows' views in the same order as `rows`. Each is only asked for where there is a
|
|
130
|
+
* drive to make or let go.
|
|
131
|
+
*/
|
|
132
|
+
drive(rows: () => readonly Row[], views: () => readonly HostNode[]): void;
|
|
133
|
+
destroy(): void;
|
|
134
|
+
/** Where a sticky row stops, pushed off by the next: that row's top, less this row's size. */
|
|
135
|
+
private stopOf;
|
|
136
|
+
/**
|
|
137
|
+
* How native moves a rendered row, or null when it does not: along the scroll view's own
|
|
138
|
+
* offset, which counts the header, from the row's top until the next sticky row pushes it off.
|
|
139
|
+
*/
|
|
140
|
+
private driveOf;
|
|
141
|
+
}
|
|
142
|
+
export {};
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
import { computed, signal } from '@angular/core';
|
|
2
|
+
import { pinnedRange, } from '@ng-native/fabric';
|
|
3
|
+
import { STICKY_SETTLE_MS } from "./sticky-headers.js";
|
|
4
|
+
/**
|
|
5
|
+
* `<virtual-list>`'s sticky rows: which one holds the leading edge, the style that pins it, the
|
|
6
|
+
* header's pinned style, and, where the host moves views by the scroll on the native side, what
|
|
7
|
+
* native is moving. The list's own share of `stickyIndices` and `stickyHeader`, as `StickyHeaders`
|
|
8
|
+
* is `<scroll-view>`'s.
|
|
9
|
+
*
|
|
10
|
+
* Pinning is not native: RN's `ScrollView.js` translates a sticky child against the scroll offset
|
|
11
|
+
* in JavaScript, and a row here follows the offset the same way while it is the current one, by
|
|
12
|
+
* its `top` when absolutely positioned and by a transform when in flow. Where native can move a
|
|
13
|
+
* view by the scroll, each sticky row instead stays at its own place in the list and native
|
|
14
|
+
* translates it on every frame the list scrolls, as RN's `ScrollViewStickyHeader` does; a
|
|
15
|
+
* translate committed from each scroll event lands a frame or more late, and on a fast fling the
|
|
16
|
+
* row shudders and comes away from the edge.
|
|
17
|
+
*/
|
|
18
|
+
export class StickyRows {
|
|
19
|
+
/** Whether native moves sticky rows. */
|
|
20
|
+
native;
|
|
21
|
+
/** The leading edge of the viewport in content space, kept only while anything is pinned. */
|
|
22
|
+
leading = signal(0, /* @ts-ignore */
|
|
23
|
+
...(ngDevMode ? [{ debugName: "leading" }] : /* istanbul ignore next */ []));
|
|
24
|
+
offset = this.leading.asReadonly();
|
|
25
|
+
engine;
|
|
26
|
+
node;
|
|
27
|
+
list;
|
|
28
|
+
/** The offset once scrolling pauses, which the settled translate of a native-moved row is from. */
|
|
29
|
+
settled = signal(0, /* @ts-ignore */
|
|
30
|
+
...(ngDevMode ? [{ debugName: "settled" }] : /* istanbul ignore next */ []));
|
|
31
|
+
settleTimer;
|
|
32
|
+
/** What native is moving, by row view, with the transform kept beside the translate. */
|
|
33
|
+
drives = new Map();
|
|
34
|
+
/** The list scrolled itself, and native has not drawn its sticky rows there yet. */
|
|
35
|
+
jumped = false;
|
|
36
|
+
/** Native has reported reaching the target, so this pass's drives are the last to need telling. */
|
|
37
|
+
landed = false;
|
|
38
|
+
/** Where the list scrolled itself to, in the scroll view, which native reports with its event. */
|
|
39
|
+
jumpedTo = 0;
|
|
40
|
+
/** Whether that scroll is animated, so native is still at its start until it reports. */
|
|
41
|
+
jumpAnimated = false;
|
|
42
|
+
/** Where native's latest event since the jump said the scroll view was, header and all. */
|
|
43
|
+
reported;
|
|
44
|
+
/** Where native's latest event of all said it was, header and all. */
|
|
45
|
+
nativeAt = 0;
|
|
46
|
+
/**
|
|
47
|
+
* Scroll end events still to come, one for each jump that moved native, as iOS sends one. Kept
|
|
48
|
+
* across jumps: one that landed has its end still to come, and must not be taken for the next's.
|
|
49
|
+
*/
|
|
50
|
+
ends = 0;
|
|
51
|
+
/** The recycling type of a sticky row of each `itemType`: apart from plain rows of it. */
|
|
52
|
+
typeOfKind = new Map();
|
|
53
|
+
types = new Set();
|
|
54
|
+
constructor(engine, node, list) {
|
|
55
|
+
this.engine = engine;
|
|
56
|
+
this.node = node;
|
|
57
|
+
this.list = list;
|
|
58
|
+
this.native = engine.drivesScroll;
|
|
59
|
+
}
|
|
60
|
+
/** Whether the scroll offset is needed as a signal, which only pinning needs. */
|
|
61
|
+
pinning = computed(() => this.list.header() || this.list.indices().length > 0, /* @ts-ignore */
|
|
62
|
+
...(ngDevMode ? [{ debugName: "pinning" }] : /* istanbul ignore next */ []));
|
|
63
|
+
/** Each sticky row, and the one after it, which pushes it off. */
|
|
64
|
+
next = computed(() => {
|
|
65
|
+
const sticky = this.list.indices();
|
|
66
|
+
return new Map(sticky.map((index, at) => [index, sticky[at + 1]]));
|
|
67
|
+
}, /* @ts-ignore */
|
|
68
|
+
...(ngDevMode ? [{ debugName: "next" }] : /* istanbul ignore next */ []));
|
|
69
|
+
/**
|
|
70
|
+
* The sticky row currently holding the leading edge: the last one at or before the offset.
|
|
71
|
+
* Null when the list has scrolled back above the first of them.
|
|
72
|
+
*/
|
|
73
|
+
pinned = computed(() => {
|
|
74
|
+
const sticky = this.list.indices();
|
|
75
|
+
if (sticky.length === 0)
|
|
76
|
+
return null;
|
|
77
|
+
const offset = this.offset();
|
|
78
|
+
let pinned = null;
|
|
79
|
+
for (const index of sticky) {
|
|
80
|
+
if (this.list.topOf(index) <= offset)
|
|
81
|
+
pinned = index;
|
|
82
|
+
else
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
return pinned;
|
|
86
|
+
}, /* @ts-ignore */
|
|
87
|
+
...(ngDevMode ? [{ debugName: "pinned" }] : /* istanbul ignore next */ []));
|
|
88
|
+
/**
|
|
89
|
+
* The header's translation while it is pinned: the scroll position, held back at zero by an
|
|
90
|
+
* overscroll and at the first sticky row, which pushes it off.
|
|
91
|
+
*/
|
|
92
|
+
headerStyle = computed(() => {
|
|
93
|
+
const flip = this.list.flipText();
|
|
94
|
+
if (!this.list.header())
|
|
95
|
+
return flip ? { transform: flip } : undefined;
|
|
96
|
+
const along = this.offset() + this.list.headerHeight();
|
|
97
|
+
const first = this.list.indices()[0];
|
|
98
|
+
const limit = first === undefined ? Infinity : this.list.topOf(first);
|
|
99
|
+
const shift = Math.min(Math.max(0, along), limit);
|
|
100
|
+
const move = shift > 0 ? `${this.list.horizontal() ? 'translateX' : 'translateY'}(${shift}px)` : '';
|
|
101
|
+
const transform = [move, flip ?? ''].filter(Boolean).join(' ');
|
|
102
|
+
return transform ? { zIndex: 1, transform } : { zIndex: 1 };
|
|
103
|
+
}, /* @ts-ignore */
|
|
104
|
+
...(ngDevMode ? [{ debugName: "headerStyle" }] : /* istanbul ignore next */ []));
|
|
105
|
+
/** A pinned row in flow, moved from where flow put it to the leading edge by a transform. */
|
|
106
|
+
flowStyle(at) {
|
|
107
|
+
const shift = Math.max(0, this.offset() - at);
|
|
108
|
+
const move = `${this.list.horizontal() ? 'translateX' : 'translateY'}(${shift}px)`;
|
|
109
|
+
const flip = this.list.flipText();
|
|
110
|
+
return { ...this.list.flowSpacing(), zIndex: 1, transform: flip ? `${move} ${flip}` : move };
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* A sticky row native moves: at its own place, with the translate native had reached when
|
|
114
|
+
* scrolling paused, so the props agree with what is on screen.
|
|
115
|
+
*/
|
|
116
|
+
style(index) {
|
|
117
|
+
const horizontal = this.list.horizontal();
|
|
118
|
+
const style = this.list.measuring()
|
|
119
|
+
? { ...this.list.flowSpacing() }
|
|
120
|
+
: { ...this.list.slotStyle(index) };
|
|
121
|
+
style['zIndex'] = 1;
|
|
122
|
+
const top = this.list.topOf(index);
|
|
123
|
+
const shift = Math.min(Math.max(0, this.settled() - top), this.stopOf(index) - top);
|
|
124
|
+
const move = shift > 0 ? `${horizontal ? 'translateX' : 'translateY'}(${shift}px)` : '';
|
|
125
|
+
const transform = [move, this.list.flipText() ?? ''].filter(Boolean).join(' ');
|
|
126
|
+
if (transform)
|
|
127
|
+
style['transform'] = transform;
|
|
128
|
+
return style;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* The recycling type of a row: a sticky row is a type of its own, since native keeps the
|
|
132
|
+
* translate it moved one by, and a plain row taking its slot commits no transform to put it
|
|
133
|
+
* back. Apart from that, `kind`, the row's `itemType`.
|
|
134
|
+
*/
|
|
135
|
+
recyclingType(index, kind) {
|
|
136
|
+
if (!this.next().has(index))
|
|
137
|
+
return kind;
|
|
138
|
+
let type = this.typeOfKind.get(kind);
|
|
139
|
+
if (!type) {
|
|
140
|
+
type = Symbol('sticky');
|
|
141
|
+
this.typeOfKind.set(kind, type);
|
|
142
|
+
this.types.add(type);
|
|
143
|
+
}
|
|
144
|
+
return type;
|
|
145
|
+
}
|
|
146
|
+
/** Whether a recycling type is a sticky row's. */
|
|
147
|
+
isType(type) {
|
|
148
|
+
return this.types.has(type);
|
|
149
|
+
}
|
|
150
|
+
/** The list scrolled, to `offset` in content space and `along` in the scroll view. */
|
|
151
|
+
scrolled(offset, along) {
|
|
152
|
+
this.nativeAt = along;
|
|
153
|
+
if (this.jumped) {
|
|
154
|
+
this.reported = along;
|
|
155
|
+
// An event from before the jump, or on the way, is not where it lands.
|
|
156
|
+
if (Math.abs(along - this.jumpedTo) <= 1)
|
|
157
|
+
this.landed = true;
|
|
158
|
+
}
|
|
159
|
+
// A pinned row follows the scroll continuously, so with sticky rows the offset has to be a
|
|
160
|
+
// signal - and only then. Without them this stays out of change detection, and a fling that
|
|
161
|
+
// moves no row in or out of the window costs none.
|
|
162
|
+
if (!this.pinning())
|
|
163
|
+
return;
|
|
164
|
+
this.leading.set(offset);
|
|
165
|
+
if (!this.native)
|
|
166
|
+
return;
|
|
167
|
+
// See `STICKY_SETTLE_MS`.
|
|
168
|
+
clearTimeout(this.settleTimer);
|
|
169
|
+
this.settleTimer = setTimeout(() => this.settled.set(offset), STICKY_SETTLE_MS);
|
|
170
|
+
}
|
|
171
|
+
/** The list is scrolling itself, to `to` in the scroll view, where native has not drawn yet. */
|
|
172
|
+
jumping(to, animated) {
|
|
173
|
+
// To where native last said it was, with no earlier jump on its way: it moves nothing and
|
|
174
|
+
// reports nothing. With one, native moves and comes back, and reports that.
|
|
175
|
+
const pending = this.jumped && !this.landed;
|
|
176
|
+
if (Math.abs(to - (pending ? this.jumpedTo : this.nativeAt)) > 1)
|
|
177
|
+
this.ends++;
|
|
178
|
+
this.jumped = pending || Math.abs(to - this.nativeAt) > 1;
|
|
179
|
+
this.landed = false;
|
|
180
|
+
this.jumpedTo = to;
|
|
181
|
+
this.jumpAnimated = animated;
|
|
182
|
+
this.reported = undefined;
|
|
183
|
+
}
|
|
184
|
+
/** The user took the scroll over: native's own events move the rows from here. */
|
|
185
|
+
dragged() {
|
|
186
|
+
this.jumped = this.landed = false;
|
|
187
|
+
// Android sends no end for a jump that is not animated, so none is waited for past a drag.
|
|
188
|
+
this.ends = 0;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* A scroll came to rest. The last of the jumps on their way has landed, wherever it did: iOS
|
|
192
|
+
* does not stop a scroll at the end of the content, so it can rest past where the list said,
|
|
193
|
+
* and what moves it next (a tap on the status bar) is not a drag.
|
|
194
|
+
*/
|
|
195
|
+
rested() {
|
|
196
|
+
if (this.ends > 0)
|
|
197
|
+
this.ends--;
|
|
198
|
+
if (this.jumped && this.ends === 0)
|
|
199
|
+
this.landed = true;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Hand each rendered sticky row's view to native to move, and let go of the rest. `views` are
|
|
203
|
+
* the rendered rows' views in the same order as `rows`. Each is only asked for where there is a
|
|
204
|
+
* drive to make or let go.
|
|
205
|
+
*/
|
|
206
|
+
drive(rows, views) {
|
|
207
|
+
if (!this.pinning() && this.drives.size === 0)
|
|
208
|
+
return;
|
|
209
|
+
const rendered = views();
|
|
210
|
+
const axis = this.list.horizontal() ? 'x' : 'y';
|
|
211
|
+
const live = new Set();
|
|
212
|
+
// After the list scrolled itself, where native is: it draws a graph when its offset changes,
|
|
213
|
+
// and after a jump the offset of a drive just made may not. What native last reported, or
|
|
214
|
+
// before it has, the target of a jump that is not animated. An animated one only once it has
|
|
215
|
+
// landed: on the way native's offset changes every frame, so it draws a new graph anyway, and
|
|
216
|
+
// the offset here trails native's and would set every pinned row back a frame. The same holds
|
|
217
|
+
// mid-fling, which is why nothing is told outside a jump.
|
|
218
|
+
const from = !this.jumped
|
|
219
|
+
? undefined
|
|
220
|
+
: this.jumpAnimated
|
|
221
|
+
? this.landed
|
|
222
|
+
? this.reported
|
|
223
|
+
: undefined
|
|
224
|
+
: (this.reported ?? this.jumpedTo);
|
|
225
|
+
rows().forEach((row, at) => {
|
|
226
|
+
const view = rendered[at];
|
|
227
|
+
const next = this.driveOf(row);
|
|
228
|
+
if (!view || !next)
|
|
229
|
+
return;
|
|
230
|
+
live.add(view);
|
|
231
|
+
const statics = JSON.stringify(next.statics);
|
|
232
|
+
const held = this.drives.get(view);
|
|
233
|
+
if (held?.statics === statics)
|
|
234
|
+
return held.drive.update(next.range, from);
|
|
235
|
+
held?.drive.stop();
|
|
236
|
+
const drive = this.engine.driveByScroll(view, this.node, axis, next.range, next.statics, from);
|
|
237
|
+
if (drive)
|
|
238
|
+
this.drives.set(view, { drive, statics });
|
|
239
|
+
});
|
|
240
|
+
for (const [view, held] of this.drives) {
|
|
241
|
+
if (live.has(view))
|
|
242
|
+
continue;
|
|
243
|
+
held.drive.stop();
|
|
244
|
+
this.drives.delete(view);
|
|
245
|
+
}
|
|
246
|
+
if (this.landed)
|
|
247
|
+
this.jumped = this.landed = false;
|
|
248
|
+
}
|
|
249
|
+
destroy() {
|
|
250
|
+
clearTimeout(this.settleTimer);
|
|
251
|
+
for (const held of this.drives.values())
|
|
252
|
+
held.drive.stop();
|
|
253
|
+
}
|
|
254
|
+
/** Where a sticky row stops, pushed off by the next: that row's top, less this row's size. */
|
|
255
|
+
stopOf(index) {
|
|
256
|
+
const next = this.next().get(index);
|
|
257
|
+
return next === undefined ? Infinity : this.list.topOf(next) - this.list.heightOf(index);
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* How native moves a rendered row, or null when it does not: along the scroll view's own
|
|
261
|
+
* offset, which counts the header, from the row's top until the next sticky row pushes it off.
|
|
262
|
+
*/
|
|
263
|
+
driveOf(row) {
|
|
264
|
+
if (!this.native || row.parked || !this.next().has(row.index))
|
|
265
|
+
return null;
|
|
266
|
+
const header = this.list.headerHeight();
|
|
267
|
+
const start = header + this.list.topOf(row.index);
|
|
268
|
+
return {
|
|
269
|
+
range: pinnedRange(start, header + this.stopOf(row.index)),
|
|
270
|
+
statics: this.list.flip() ?? [],
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
//# sourceMappingURL=sticky-rows.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sticky-rows.js","sourceRoot":"","sources":["../src/sticky-rows.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAe,MAAM,eAAe,CAAC;AAC9D,OAAO,EAML,WAAW,GACZ,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AA6BvD;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,UAAU;IACrB,wCAAwC;IAC/B,MAAM,CAAU;IACzB,6FAA6F;IAC5E,OAAO,GAAG,MAAM,CAAC,CAAC;gFAAC,CAAC;IAC5B,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC;IAE3B,MAAM,CAAa;IACnB,IAAI,CAAW;IACf,IAAI,CAAiB;IACtC,mGAAmG;IAClF,OAAO,GAAG,MAAM,CAAC,CAAC;gFAAC,CAAC;IAC7B,WAAW,CAA4C;IAC/D,wFAAwF;IACvE,MAAM,GAAG,IAAI,GAAG,EAAqD,CAAC;IACvF,oFAAoF;IAC5E,MAAM,GAAG,KAAK,CAAC;IACvB,mGAAmG;IAC3F,MAAM,GAAG,KAAK,CAAC;IACvB,kGAAkG;IAC1F,QAAQ,GAAG,CAAC,CAAC;IACrB,yFAAyF;IACjF,YAAY,GAAG,KAAK,CAA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I,EAAE;SAChC,CAAC;IACJ,CAAC;CACF","sourcesContent":["import { computed, signal, type Signal } from '@angular/core';\nimport {\n type HostEngine,\n type HostNode,\n type ScrollDrive,\n type ScrollRange,\n type StaticTransform,\n pinnedRange,\n} from '@ng-native/fabric';\nimport { STICKY_SETTLE_MS } from './sticky-headers.ts';\n\n/** What `StickyRows` needs of the list whose rows it pins. */\nexport interface StickyRowsList {\n /** The sticky rows' indices, as `stickyIndices` gives them. */\n readonly indices: Signal<readonly number[]>;\n /** Whether the list header is pinned too, as `stickyHeader` says. */\n readonly header: Signal<boolean>;\n readonly headerHeight: Signal<number>;\n horizontal(): boolean;\n /** Rows size themselves and are laid out in flow. */\n measuring(): boolean;\n topOf(index: number): number;\n heightOf(index: number): number;\n /** An absolutely positioned row's style, at its own place. */\n slotStyle(index: number): Record<string, unknown>;\n /** What places a row in flow. */\n flowSpacing(): Record<string, unknown>;\n /** The list's flip, as transforms and as CSS text, when it is inverted. */\n flip(): readonly StaticTransform[] | undefined;\n flipText(): string | undefined;\n}\n\n/** A row as the list renders it, for what `StickyRows` reads of it. */\ninterface Row {\n readonly index: number;\n readonly parked?: boolean;\n}\n\n/**\n * `<virtual-list>`'s sticky rows: which one holds the leading edge, the style that pins it, the\n * header's pinned style, and, where the host moves views by the scroll on the native side, what\n * native is moving. The list's own share of `stickyIndices` and `stickyHeader`, as `StickyHeaders`\n * is `<scroll-view>`'s.\n *\n * Pinning is not native: RN's `ScrollView.js` translates a sticky child against the scroll offset\n * in JavaScript, and a row here follows the offset the same way while it is the current one, by\n * its `top` when absolutely positioned and by a transform when in flow. Where native can move a\n * view by the scroll, each sticky row instead stays at its own place in the list and native\n * translates it on every frame the list scrolls, as RN's `ScrollViewStickyHeader` does; a\n * translate committed from each scroll event lands a frame or more late, and on a fast fling the\n * row shudders and comes away from the edge.\n */\nexport class StickyRows {\n /** Whether native moves sticky rows. */\n readonly native: boolean;\n /** The leading edge of the viewport in content space, kept only while anything is pinned. */\n private readonly leading = signal(0);\n readonly offset = this.leading.asReadonly();\n\n private readonly engine: HostEngine;\n private readonly node: HostNode;\n private readonly list: StickyRowsList;\n /** The offset once scrolling pauses, which the settled translate of a native-moved row is from. */\n private readonly settled = signal(0);\n private settleTimer: ReturnType<typeof setTimeout> | undefined;\n /** What native is moving, by row view, with the transform kept beside the translate. */\n private readonly drives = new Map<HostNode, { drive: ScrollDrive; statics: string }>();\n /** The list scrolled itself, and native has not drawn its sticky rows there yet. */\n private jumped = false;\n /** Native has reported reaching the target, so this pass's drives are the last to need telling. */\n private landed = false;\n /** Where the list scrolled itself to, in the scroll view, which native reports with its event. */\n private jumpedTo = 0;\n /** Whether that scroll is animated, so native is still at its start until it reports. */\n private jumpAnimated = false;\n /** Where native's latest event since the jump said the scroll view was, header and all. */\n private reported: number | undefined;\n /** Where native's latest event of all said it was, header and all. */\n private nativeAt = 0;\n /**\n * Scroll end events still to come, one for each jump that moved native, as iOS sends one. Kept\n * across jumps: one that landed has its end still to come, and must not be taken for the next's.\n */\n private ends = 0;\n /** The recycling type of a sticky row of each `itemType`: apart from plain rows of it. */\n private readonly typeOfKind = new Map<unknown, symbol>();\n private readonly types = new Set<unknown>();\n\n constructor(engine: HostEngine, node: HostNode, list: StickyRowsList) {\n this.engine = engine;\n this.node = node;\n this.list = list;\n this.native = engine.drivesScroll;\n }\n\n /** Whether the scroll offset is needed as a signal, which only pinning needs. */\n private readonly pinning = computed(() => this.list.header() || this.list.indices().length > 0);\n\n /** Each sticky row, and the one after it, which pushes it off. */\n readonly next = computed(() => {\n const sticky = this.list.indices();\n return new Map(sticky.map((index, at) => [index, sticky[at + 1]]));\n });\n\n /**\n * The sticky row currently holding the leading edge: the last one at or before the offset.\n * Null when the list has scrolled back above the first of them.\n */\n readonly pinned = computed<number | null>(() => {\n const sticky = this.list.indices();\n if (sticky.length === 0) return null;\n const offset = this.offset();\n\n let pinned: number | null = null;\n for (const index of sticky) {\n if (this.list.topOf(index) <= offset) pinned = index;\n else break;\n }\n return pinned;\n });\n\n /**\n * The header's translation while it is pinned: the scroll position, held back at zero by an\n * overscroll and at the first sticky row, which pushes it off.\n */\n readonly headerStyle = computed(() => {\n const flip = this.list.flipText();\n if (!this.list.header()) return flip ? { transform: flip } : undefined;\n const along = this.offset() + this.list.headerHeight();\n const first = this.list.indices()[0];\n const limit = first === undefined ? Infinity : this.list.topOf(first);\n const shift = Math.min(Math.max(0, along), limit);\n const move =\n shift > 0 ? `${this.list.horizontal() ? 'translateX' : 'translateY'}(${shift}px)` : '';\n const transform = [move, flip ?? ''].filter(Boolean).join(' ');\n return transform ? { zIndex: 1, transform } : { zIndex: 1 };\n });\n\n /** A pinned row in flow, moved from where flow put it to the leading edge by a transform. */\n flowStyle(at: number): Record<string, unknown> {\n const shift = Math.max(0, this.offset() - at);\n const move = `${this.list.horizontal() ? 'translateX' : 'translateY'}(${shift}px)`;\n const flip = this.list.flipText();\n return { ...this.list.flowSpacing(), zIndex: 1, transform: flip ? `${move} ${flip}` : move };\n }\n\n /**\n * A sticky row native moves: at its own place, with the translate native had reached when\n * scrolling paused, so the props agree with what is on screen.\n */\n style(index: number): Record<string, unknown> {\n const horizontal = this.list.horizontal();\n const style: Record<string, unknown> = this.list.measuring()\n ? { ...this.list.flowSpacing() }\n : { ...this.list.slotStyle(index) };\n style['zIndex'] = 1;\n const top = this.list.topOf(index);\n const shift = Math.min(Math.max(0, this.settled() - top), this.stopOf(index) - top);\n const move = shift > 0 ? `${horizontal ? 'translateX' : 'translateY'}(${shift}px)` : '';\n const transform = [move, this.list.flipText() ?? ''].filter(Boolean).join(' ');\n if (transform) style['transform'] = transform;\n return style;\n }\n\n /**\n * The recycling type of a row: a sticky row is a type of its own, since native keeps the\n * translate it moved one by, and a plain row taking its slot commits no transform to put it\n * back. Apart from that, `kind`, the row's `itemType`.\n */\n recyclingType(index: number, kind: unknown): unknown {\n if (!this.next().has(index)) return kind;\n let type = this.typeOfKind.get(kind);\n if (!type) {\n type = Symbol('sticky');\n this.typeOfKind.set(kind, type);\n this.types.add(type);\n }\n return type;\n }\n\n /** Whether a recycling type is a sticky row's. */\n isType(type: unknown): boolean {\n return this.types.has(type);\n }\n\n /** The list scrolled, to `offset` in content space and `along` in the scroll view. */\n scrolled(offset: number, along: number): void {\n this.nativeAt = along;\n if (this.jumped) {\n this.reported = along;\n // An event from before the jump, or on the way, is not where it lands.\n if (Math.abs(along - this.jumpedTo) <= 1) this.landed = true;\n }\n // A pinned row follows the scroll continuously, so with sticky rows the offset has to be a\n // signal - and only then. Without them this stays out of change detection, and a fling that\n // moves no row in or out of the window costs none.\n if (!this.pinning()) return;\n this.leading.set(offset);\n if (!this.native) return;\n // See `STICKY_SETTLE_MS`.\n clearTimeout(this.settleTimer);\n this.settleTimer = setTimeout(() => this.settled.set(offset), STICKY_SETTLE_MS);\n }\n\n /** The list is scrolling itself, to `to` in the scroll view, where native has not drawn yet. */\n jumping(to: number, animated: boolean): void {\n // To where native last said it was, with no earlier jump on its way: it moves nothing and\n // reports nothing. With one, native moves and comes back, and reports that.\n const pending = this.jumped && !this.landed;\n if (Math.abs(to - (pending ? this.jumpedTo : this.nativeAt)) > 1) this.ends++;\n this.jumped = pending || Math.abs(to - this.nativeAt) > 1;\n this.landed = false;\n this.jumpedTo = to;\n this.jumpAnimated = animated;\n this.reported = undefined;\n }\n\n /** The user took the scroll over: native's own events move the rows from here. */\n dragged(): void {\n this.jumped = this.landed = false;\n // Android sends no end for a jump that is not animated, so none is waited for past a drag.\n this.ends = 0;\n }\n\n /**\n * A scroll came to rest. The last of the jumps on their way has landed, wherever it did: iOS\n * does not stop a scroll at the end of the content, so it can rest past where the list said,\n * and what moves it next (a tap on the status bar) is not a drag.\n */\n rested(): void {\n if (this.ends > 0) this.ends--;\n if (this.jumped && this.ends === 0) this.landed = true;\n }\n\n /**\n * Hand each rendered sticky row's view to native to move, and let go of the rest. `views` are\n * the rendered rows' views in the same order as `rows`. Each is only asked for where there is a\n * drive to make or let go.\n */\n drive(rows: () => readonly Row[], views: () => readonly HostNode[]): void {\n if (!this.pinning() && this.drives.size === 0) return;\n const rendered = views();\n const axis = this.list.horizontal() ? 'x' : 'y';\n const live = new Set<HostNode>();\n // After the list scrolled itself, where native is: it draws a graph when its offset changes,\n // and after a jump the offset of a drive just made may not. What native last reported, or\n // before it has, the target of a jump that is not animated. An animated one only once it has\n // landed: on the way native's offset changes every frame, so it draws a new graph anyway, and\n // the offset here trails native's and would set every pinned row back a frame. The same holds\n // mid-fling, which is why nothing is told outside a jump.\n const from = !this.jumped\n ? undefined\n : this.jumpAnimated\n ? this.landed\n ? this.reported\n : undefined\n : (this.reported ?? this.jumpedTo);\n rows().forEach((row, at) => {\n const view = rendered[at];\n const next = this.driveOf(row);\n if (!view || !next) return;\n live.add(view);\n const statics = JSON.stringify(next.statics);\n const held = this.drives.get(view);\n if (held?.statics === statics) return held.drive.update(next.range, from);\n held?.drive.stop();\n const drive = this.engine.driveByScroll(\n view,\n this.node,\n axis,\n next.range,\n next.statics,\n from,\n );\n if (drive) this.drives.set(view, { drive, statics });\n });\n for (const [view, held] of this.drives) {\n if (live.has(view)) continue;\n held.drive.stop();\n this.drives.delete(view);\n }\n if (this.landed) this.jumped = this.landed = false;\n }\n\n destroy(): void {\n clearTimeout(this.settleTimer);\n for (const held of this.drives.values()) held.drive.stop();\n }\n\n /** Where a sticky row stops, pushed off by the next: that row's top, less this row's size. */\n private stopOf(index: number): number {\n const next = this.next().get(index);\n return next === undefined ? Infinity : this.list.topOf(next) - this.list.heightOf(index);\n }\n\n /**\n * How native moves a rendered row, or null when it does not: along the scroll view's own\n * offset, which counts the header, from the row's top until the next sticky row pushes it off.\n */\n private driveOf(row: Row): { range: ScrollRange; statics: readonly StaticTransform[] } | null {\n if (!this.native || row.parked || !this.next().has(row.index)) return null;\n const header = this.list.headerHeight();\n const start = header + this.list.topOf(row.index);\n return {\n range: pinnedRange(start, header + this.stopOf(row.index)),\n statics: this.list.flip() ?? [],\n };\n }\n}\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How `<virtual-list>` lays items out across its width, when a directive on the list says so.
|
|
3
|
+
*
|
|
4
|
+
* The list places items along its axis and windows them; how many share a line and where each
|
|
5
|
+
* sits across it is a separate decision, and a list that never makes it carries none of its code.
|
|
6
|
+
* A directive on the list's own element provides this, as `[contextMenu]` provides `CONTEXT_MENU`
|
|
7
|
+
* to `<pressable>`, and the list reads it with `{ self: true, optional: true }`.
|
|
8
|
+
*/
|
|
9
|
+
import { InjectionToken, type Signal } from '@angular/core';
|
|
10
|
+
export interface VirtualListLayout {
|
|
11
|
+
/** How many items go on a line. One is a plain list. */
|
|
12
|
+
readonly columns: Signal<number>;
|
|
13
|
+
/**
|
|
14
|
+
* The props that place the item in `column` across a line, given the list's own insets on its
|
|
15
|
+
* left and right. Column 0 is at the start of the line, so the props are logical sides, which
|
|
16
|
+
* layout resolves by direction as React Native resolves the list's own left and right. Every
|
|
17
|
+
* column's props name the same keys, so moving between columns overwrites them all.
|
|
18
|
+
*/
|
|
19
|
+
across(column: number, left: number, right: number): Record<string, unknown>;
|
|
20
|
+
}
|
|
21
|
+
export declare const VIRTUAL_LIST_LAYOUT: InjectionToken<VirtualListLayout>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How `<virtual-list>` lays items out across its width, when a directive on the list says so.
|
|
3
|
+
*
|
|
4
|
+
* The list places items along its axis and windows them; how many share a line and where each
|
|
5
|
+
* sits across it is a separate decision, and a list that never makes it carries none of its code.
|
|
6
|
+
* A directive on the list's own element provides this, as `[contextMenu]` provides `CONTEXT_MENU`
|
|
7
|
+
* to `<pressable>`, and the list reads it with `{ self: true, optional: true }`.
|
|
8
|
+
*/
|
|
9
|
+
import { InjectionToken } from '@angular/core';
|
|
10
|
+
export const VIRTUAL_LIST_LAYOUT = new InjectionToken('angular-native.virtualListLayout');
|
|
11
|
+
//# sourceMappingURL=virtual-list-layout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"virtual-list-layout.js","sourceRoot":"","sources":["../src/virtual-list-layout.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,cAAc,EAAe,MAAM,eAAe,CAAC;AAc5D,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,cAAc,CACnD,kCAAkC,CACnC,CAAC","sourcesContent":["/**\n * How `<virtual-list>` lays items out across its width, when a directive on the list says so.\n *\n * The list places items along its axis and windows them; how many share a line and where each\n * sits across it is a separate decision, and a list that never makes it carries none of its code.\n * A directive on the list's own element provides this, as `[contextMenu]` provides `CONTEXT_MENU`\n * to `<pressable>`, and the list reads it with `{ self: true, optional: true }`.\n */\nimport { InjectionToken, type Signal } from '@angular/core';\n\nexport interface VirtualListLayout {\n /** How many items go on a line. One is a plain list. */\n readonly columns: Signal<number>;\n /**\n * The props that place the item in `column` across a line, given the list's own insets on its\n * left and right. Column 0 is at the start of the line, so the props are logical sides, which\n * layout resolves by direction as React Native resolves the list's own left and right. Every\n * column's props name the same keys, so moving between columns overwrites them all.\n */\n across(column: number, left: number, right: number): Record<string, unknown>;\n}\n\nexport const VIRTUAL_LIST_LAYOUT = new InjectionToken<VirtualListLayout>(\n 'angular-native.virtualListLayout',\n);\n"]}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { type VirtualListLayout } from './virtual-list-layout.ts';
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
/**
|
|
4
|
+
* FlatList's `numColumns`, on `<virtual-list>` itself: a photo grid or a shop's products, windowed
|
|
5
|
+
* a line at a time.
|
|
6
|
+
*
|
|
7
|
+
* ```html
|
|
8
|
+
* <virtual-list #list [items]="photos" [itemHeight]="120" [rowGap]="2"
|
|
9
|
+
* [virtualListNumColumns]="3" [virtualListColumnGap]="2">
|
|
10
|
+
* @for (row of list.window(); track row.slot) {
|
|
11
|
+
* <image [virtualListRow]="row" [source]="row.item.uri" />
|
|
12
|
+
* }
|
|
13
|
+
* </virtual-list>
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* Each item is still one row of the window, with its own slot, key and recycling, so the `@for`
|
|
17
|
+
* is the same as a plain list's. Items fill a line left to right, right to left in a
|
|
18
|
+
* right-to-left layout, and every column is the same width. A line is as tall as its tallest item,
|
|
19
|
+
* and its items stretch to it, as they do in FlatList's row. A sticky row takes a line to itself,
|
|
20
|
+
* so a month's header pins across the whole grid.
|
|
21
|
+
*
|
|
22
|
+
* Columns are for vertical lists with `itemHeight`, as FlatList's `numColumns` is vertical only.
|
|
23
|
+
*
|
|
24
|
+
* ponytail: rows that size themselves stay one to a line, with a warning in development, since a
|
|
25
|
+
* line's height would wait on every item in it measuring. FlatList's `columnWrapperStyle` has no
|
|
26
|
+
* equivalent: there is no view per line to style. A separator is drawn under each item but the
|
|
27
|
+
* last line's, with the next line's first item as its `trailingItem`, where FlatList draws one a
|
|
28
|
+
* line.
|
|
29
|
+
*/
|
|
30
|
+
export declare class VirtualListNumColumns implements VirtualListLayout {
|
|
31
|
+
/** Items to a line, as FlatList's `numColumns`. */
|
|
32
|
+
readonly numColumns: import("@angular/core").InputSignalWithTransform<number, unknown>;
|
|
33
|
+
/** Space between one column and the next. `rowGap` on the list spaces the lines. */
|
|
34
|
+
readonly columnGap: import("@angular/core").InputSignalWithTransform<number, unknown>;
|
|
35
|
+
private readonly injector;
|
|
36
|
+
readonly columns: import("@angular/core").Signal<number>;
|
|
37
|
+
constructor();
|
|
38
|
+
/**
|
|
39
|
+
* Each column is an equal share of the width, as a percentage, so the line needs no width to
|
|
40
|
+
* be laid out and follows a rotation without one. The padding and gaps are then taken out by
|
|
41
|
+
* margins: every column gives up the same amount, and how much of it is on which side is what
|
|
42
|
+
* puts the gaps between the columns rather than inside them.
|
|
43
|
+
*/
|
|
44
|
+
across(column: number, left: number, right: number): Record<string, unknown>;
|
|
45
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<VirtualListNumColumns, never>;
|
|
46
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<VirtualListNumColumns, "virtual-list[virtualListNumColumns]", never, { "numColumns": { "alias": "virtualListNumColumns"; "required": false; "isSignal": true; }; "columnGap": { "alias": "virtualListColumnGap"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
47
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { Directive, Injector, computed, effect, forwardRef, inject, input } from '@angular/core';
|
|
2
|
+
import { numberOr } from "./transforms.js";
|
|
3
|
+
import { VirtualList } from "./virtual-list.js";
|
|
4
|
+
import { VIRTUAL_LIST_LAYOUT } from "./virtual-list-layout.js";
|
|
5
|
+
import * as i0 from "@angular/core";
|
|
6
|
+
/**
|
|
7
|
+
* FlatList's `numColumns`, on `<virtual-list>` itself: a photo grid or a shop's products, windowed
|
|
8
|
+
* a line at a time.
|
|
9
|
+
*
|
|
10
|
+
* ```html
|
|
11
|
+
* <virtual-list #list [items]="photos" [itemHeight]="120" [rowGap]="2"
|
|
12
|
+
* [virtualListNumColumns]="3" [virtualListColumnGap]="2">
|
|
13
|
+
* @for (row of list.window(); track row.slot) {
|
|
14
|
+
* <image [virtualListRow]="row" [source]="row.item.uri" />
|
|
15
|
+
* }
|
|
16
|
+
* </virtual-list>
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* Each item is still one row of the window, with its own slot, key and recycling, so the `@for`
|
|
20
|
+
* is the same as a plain list's. Items fill a line left to right, right to left in a
|
|
21
|
+
* right-to-left layout, and every column is the same width. A line is as tall as its tallest item,
|
|
22
|
+
* and its items stretch to it, as they do in FlatList's row. A sticky row takes a line to itself,
|
|
23
|
+
* so a month's header pins across the whole grid.
|
|
24
|
+
*
|
|
25
|
+
* Columns are for vertical lists with `itemHeight`, as FlatList's `numColumns` is vertical only.
|
|
26
|
+
*
|
|
27
|
+
* ponytail: rows that size themselves stay one to a line, with a warning in development, since a
|
|
28
|
+
* line's height would wait on every item in it measuring. FlatList's `columnWrapperStyle` has no
|
|
29
|
+
* equivalent: there is no view per line to style. A separator is drawn under each item but the
|
|
30
|
+
* last line's, with the next line's first item as its `trailingItem`, where FlatList draws one a
|
|
31
|
+
* line.
|
|
32
|
+
*/
|
|
33
|
+
export class VirtualListNumColumns {
|
|
34
|
+
/** Items to a line, as FlatList's `numColumns`. */
|
|
35
|
+
numColumns = input(1, { ...(ngDevMode ? { debugName: "numColumns" } : /* istanbul ignore next */ {}), alias: 'virtualListNumColumns', transform: numberOr(1) });
|
|
36
|
+
/** Space between one column and the next. `rowGap` on the list spaces the lines. */
|
|
37
|
+
columnGap = input(0, { ...(ngDevMode ? { debugName: "columnGap" } : /* istanbul ignore next */ {}), alias: 'virtualListColumnGap', transform: numberOr(0) });
|
|
38
|
+
// Looked up once the list exists: the list injects this directive while it is being made.
|
|
39
|
+
injector = inject(Injector);
|
|
40
|
+
columns = computed(() => {
|
|
41
|
+
const columns = this.numColumns();
|
|
42
|
+
return Number.isFinite(columns) ? Math.max(1, Math.floor(columns)) : 1;
|
|
43
|
+
}, /* @ts-ignore */
|
|
44
|
+
...(ngDevMode ? [{ debugName: "columns" }] : /* istanbul ignore next */ []));
|
|
45
|
+
constructor() {
|
|
46
|
+
if (typeof ngDevMode === 'undefined' || !ngDevMode)
|
|
47
|
+
return;
|
|
48
|
+
const unsupported = effect(() => {
|
|
49
|
+
if (this.columns() === 1)
|
|
50
|
+
return;
|
|
51
|
+
const list = this.injector.get(VirtualList, null, { self: true });
|
|
52
|
+
const why = list?.horizontal()
|
|
53
|
+
? 'a horizontal list'
|
|
54
|
+
: list?.measuring()
|
|
55
|
+
? 'rows without itemHeight'
|
|
56
|
+
: null;
|
|
57
|
+
if (!why)
|
|
58
|
+
return;
|
|
59
|
+
unsupported.destroy();
|
|
60
|
+
console.warn(`[angular-native] virtualListNumColumns lays out one item a line on ${why}: columns ` +
|
|
61
|
+
`are for a vertical list with itemHeight, as FlatList's numColumns is vertical only.`);
|
|
62
|
+
}, /* @ts-ignore */
|
|
63
|
+
...(ngDevMode ? [{ debugName: "unsupported" }] : /* istanbul ignore next */ []));
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Each column is an equal share of the width, as a percentage, so the line needs no width to
|
|
67
|
+
* be laid out and follows a rotation without one. The padding and gaps are then taken out by
|
|
68
|
+
* margins: every column gives up the same amount, and how much of it is on which side is what
|
|
69
|
+
* puts the gaps between the columns rather than inside them.
|
|
70
|
+
*/
|
|
71
|
+
across(column, left, right) {
|
|
72
|
+
const columns = this.columns();
|
|
73
|
+
const gap = this.columnGap();
|
|
74
|
+
const spare = (left + right + (columns - 1) * gap) / columns;
|
|
75
|
+
const marginStart = left - (column * (left + right - gap)) / columns;
|
|
76
|
+
return {
|
|
77
|
+
start: `${(column * 100) / columns}%`,
|
|
78
|
+
end: `${((columns - 1 - column) * 100) / columns}%`,
|
|
79
|
+
marginStart,
|
|
80
|
+
marginEnd: spare - marginStart,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: VirtualListNumColumns, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
84
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.2.0", type: VirtualListNumColumns, isStandalone: true, selector: "virtual-list[virtualListNumColumns]", inputs: { numColumns: { classPropertyName: "numColumns", publicName: "virtualListNumColumns", isSignal: true, isRequired: false, transformFunction: null }, columnGap: { classPropertyName: "columnGap", publicName: "virtualListColumnGap", isSignal: true, isRequired: false, transformFunction: null } }, providers: [
|
|
85
|
+
{ provide: VIRTUAL_LIST_LAYOUT, useExisting: forwardRef(() => VirtualListNumColumns) },
|
|
86
|
+
], ngImport: i0 });
|
|
87
|
+
}
|
|
88
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: VirtualListNumColumns, decorators: [{
|
|
89
|
+
type: Directive,
|
|
90
|
+
args: [{
|
|
91
|
+
selector: 'virtual-list[virtualListNumColumns]',
|
|
92
|
+
providers: [
|
|
93
|
+
{ provide: VIRTUAL_LIST_LAYOUT, useExisting: forwardRef(() => VirtualListNumColumns) },
|
|
94
|
+
],
|
|
95
|
+
}]
|
|
96
|
+
}], ctorParameters: () => [], propDecorators: { numColumns: [{ type: i0.Input, args: [{ isSignal: true, alias: "virtualListNumColumns", required: false }] }], columnGap: [{ type: i0.Input, args: [{ isSignal: true, alias: "virtualListColumnGap", required: false }] }] } });
|
|
97
|
+
//# sourceMappingURL=virtual-list-num-columns.js.map
|