@breadstone/mosaik-elements-svelte 0.0.230 → 0.0.232
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/CHANGELOG.md +61 -0
- package/flow-BYP4Q42j.mjs +396 -0
- package/index.mjs +145231 -156991
- package/package.json +3 -4
- package/flow-qEL7lfCR.mjs +0 -493
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@breadstone/mosaik-elements-svelte",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.232",
|
|
4
4
|
"description": "Mosaik elements for Svelte.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "andre.wehlert <awehlert@breadstone.de> (https://www.breadstone.de)",
|
|
@@ -15,9 +15,8 @@
|
|
|
15
15
|
"vite": "*"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@breadstone/mosaik-elements": "^0.0.
|
|
19
|
-
"@breadstone/mosaik-elements-foundation": "^0.0.
|
|
20
|
-
"tslib": "^2.8.1"
|
|
18
|
+
"@breadstone/mosaik-elements": "^0.0.232",
|
|
19
|
+
"@breadstone/mosaik-elements-foundation": "^0.0.232"
|
|
21
20
|
},
|
|
22
21
|
"exports": {
|
|
23
22
|
".": {
|
package/flow-qEL7lfCR.mjs
DELETED
|
@@ -1,493 +0,0 @@
|
|
|
1
|
-
class g {
|
|
2
|
-
constructor(i) {
|
|
3
|
-
this._map = /* @__PURE__ */ new Map(), this._roundAverageSize = !1, this.totalSize = 0, i?.roundAverageSize === !0 && (this._roundAverageSize = !0);
|
|
4
|
-
}
|
|
5
|
-
set(i, t) {
|
|
6
|
-
const s = this._map.get(i) || 0;
|
|
7
|
-
this._map.set(i, t), this.totalSize += t - s;
|
|
8
|
-
}
|
|
9
|
-
get averageSize() {
|
|
10
|
-
if (this._map.size > 0) {
|
|
11
|
-
const i = this.totalSize / this._map.size;
|
|
12
|
-
return this._roundAverageSize ? Math.round(i) : i;
|
|
13
|
-
}
|
|
14
|
-
return 0;
|
|
15
|
-
}
|
|
16
|
-
getSize(i) {
|
|
17
|
-
return this._map.get(i);
|
|
18
|
-
}
|
|
19
|
-
clear() {
|
|
20
|
-
this._map.clear(), this.totalSize = 0;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
function f(n) {
|
|
24
|
-
return n === "horizontal" ? "width" : "height";
|
|
25
|
-
}
|
|
26
|
-
class d {
|
|
27
|
-
_getDefaultConfig() {
|
|
28
|
-
return {
|
|
29
|
-
direction: "vertical"
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
constructor(i, t) {
|
|
33
|
-
this._latestCoords = { left: 0, top: 0 }, this._direction = null, this._viewportSize = { width: 0, height: 0 }, this.totalScrollSize = { width: 0, height: 0 }, this.offsetWithinScroller = { left: 0, top: 0 }, this._pendingReflow = !1, this._pendingLayoutUpdate = !1, this._pin = null, this._firstVisible = 0, this._lastVisible = 0, this._physicalMin = 0, this._physicalMax = 0, this._first = -1, this._last = -1, this._sizeDim = "height", this._secondarySizeDim = "width", this._positionDim = "top", this._secondaryPositionDim = "left", this._scrollPosition = 0, this._scrollError = 0, this._items = [], this._scrollSize = 1, this._overhang = 1e3, this._hostSink = i, Promise.resolve().then(() => this.config = t || this._getDefaultConfig());
|
|
34
|
-
}
|
|
35
|
-
set config(i) {
|
|
36
|
-
Object.assign(this, Object.assign({}, this._getDefaultConfig(), i));
|
|
37
|
-
}
|
|
38
|
-
get config() {
|
|
39
|
-
return {
|
|
40
|
-
direction: this.direction
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Maximum index of children + 1, to help estimate total height of the scroll
|
|
45
|
-
* space.
|
|
46
|
-
*/
|
|
47
|
-
get items() {
|
|
48
|
-
return this._items;
|
|
49
|
-
}
|
|
50
|
-
set items(i) {
|
|
51
|
-
this._setItems(i);
|
|
52
|
-
}
|
|
53
|
-
_setItems(i) {
|
|
54
|
-
i !== this._items && (this._items = i, this._scheduleReflow());
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Primary scrolling direction.
|
|
58
|
-
*/
|
|
59
|
-
get direction() {
|
|
60
|
-
return this._direction;
|
|
61
|
-
}
|
|
62
|
-
set direction(i) {
|
|
63
|
-
i = i === "horizontal" ? i : "vertical", i !== this._direction && (this._direction = i, this._sizeDim = i === "horizontal" ? "width" : "height", this._secondarySizeDim = i === "horizontal" ? "height" : "width", this._positionDim = i === "horizontal" ? "left" : "top", this._secondaryPositionDim = i === "horizontal" ? "top" : "left", this._triggerReflow());
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Height and width of the viewport.
|
|
67
|
-
*/
|
|
68
|
-
get viewportSize() {
|
|
69
|
-
return this._viewportSize;
|
|
70
|
-
}
|
|
71
|
-
set viewportSize(i) {
|
|
72
|
-
const { _viewDim1: t, _viewDim2: s } = this;
|
|
73
|
-
Object.assign(this._viewportSize, i), s !== this._viewDim2 ? this._scheduleLayoutUpdate() : t !== this._viewDim1 && this._checkThresholds();
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Scroll offset of the viewport.
|
|
77
|
-
*/
|
|
78
|
-
get viewportScroll() {
|
|
79
|
-
return this._latestCoords;
|
|
80
|
-
}
|
|
81
|
-
set viewportScroll(i) {
|
|
82
|
-
Object.assign(this._latestCoords, i);
|
|
83
|
-
const t = this._scrollPosition;
|
|
84
|
-
this._scrollPosition = this._latestCoords[this._positionDim], Math.abs(t - this._scrollPosition) >= 1 && this._checkThresholds();
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Perform a reflow if one has been scheduled.
|
|
88
|
-
*/
|
|
89
|
-
reflowIfNeeded(i = !1) {
|
|
90
|
-
(i || this._pendingReflow) && (this._pendingReflow = !1, this._reflow());
|
|
91
|
-
}
|
|
92
|
-
set pin(i) {
|
|
93
|
-
this._pin = i, this._triggerReflow();
|
|
94
|
-
}
|
|
95
|
-
get pin() {
|
|
96
|
-
if (this._pin !== null) {
|
|
97
|
-
const { index: i, block: t } = this._pin;
|
|
98
|
-
return {
|
|
99
|
-
index: Math.max(0, Math.min(i, this.items.length - 1)),
|
|
100
|
-
block: t
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
return null;
|
|
104
|
-
}
|
|
105
|
-
_clampScrollPosition(i) {
|
|
106
|
-
return Math.max(-this.offsetWithinScroller[this._positionDim], Math.min(i, this.totalScrollSize[f(this.direction)] - this._viewDim1));
|
|
107
|
-
}
|
|
108
|
-
unpin() {
|
|
109
|
-
this._pin !== null && (this._sendUnpinnedMessage(), this._pin = null);
|
|
110
|
-
}
|
|
111
|
-
_updateLayout() {
|
|
112
|
-
}
|
|
113
|
-
// protected _viewDim2Changed(): void {
|
|
114
|
-
// this._scheduleLayoutUpdate();
|
|
115
|
-
// }
|
|
116
|
-
/**
|
|
117
|
-
* The height or width of the viewport, whichever corresponds to the scrolling direction.
|
|
118
|
-
*/
|
|
119
|
-
get _viewDim1() {
|
|
120
|
-
return this._viewportSize[this._sizeDim];
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* The height or width of the viewport, whichever does NOT correspond to the scrolling direction.
|
|
124
|
-
*/
|
|
125
|
-
get _viewDim2() {
|
|
126
|
-
return this._viewportSize[this._secondarySizeDim];
|
|
127
|
-
}
|
|
128
|
-
_scheduleReflow() {
|
|
129
|
-
this._pendingReflow = !0;
|
|
130
|
-
}
|
|
131
|
-
_scheduleLayoutUpdate() {
|
|
132
|
-
this._pendingLayoutUpdate = !0, this._scheduleReflow();
|
|
133
|
-
}
|
|
134
|
-
// For triggering a reflow based on incoming changes to
|
|
135
|
-
// the layout config.
|
|
136
|
-
_triggerReflow() {
|
|
137
|
-
this._scheduleLayoutUpdate(), Promise.resolve().then(() => this.reflowIfNeeded());
|
|
138
|
-
}
|
|
139
|
-
_reflow() {
|
|
140
|
-
this._pendingLayoutUpdate && (this._updateLayout(), this._pendingLayoutUpdate = !1), this._updateScrollSize(), this._setPositionFromPin(), this._getActiveItems(), this._updateVisibleIndices(), this._sendStateChangedMessage();
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
|
-
* If we are supposed to be pinned to a particular
|
|
144
|
-
* item or set of coordinates, we set `_scrollPosition`
|
|
145
|
-
* accordingly and adjust `_scrollError` as needed
|
|
146
|
-
* so that the virtualizer can keep the scroll
|
|
147
|
-
* position in the DOM in sync
|
|
148
|
-
*/
|
|
149
|
-
_setPositionFromPin() {
|
|
150
|
-
if (this.pin !== null) {
|
|
151
|
-
const i = this._scrollPosition, { index: t, block: s } = this.pin;
|
|
152
|
-
this._scrollPosition = this._calculateScrollIntoViewPosition({
|
|
153
|
-
index: t,
|
|
154
|
-
block: s || "start"
|
|
155
|
-
}) - this.offsetWithinScroller[this._positionDim], this._scrollError = i - this._scrollPosition;
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
/**
|
|
159
|
-
* Calculate the coordinates to scroll to, given
|
|
160
|
-
* a request to scroll to the element at a specific
|
|
161
|
-
* index.
|
|
162
|
-
*
|
|
163
|
-
* Supports the same positioning options (`start`,
|
|
164
|
-
* `center`, `end`, `nearest`) as the standard
|
|
165
|
-
* `Element.scrollIntoView()` method, but currently
|
|
166
|
-
* only considers the provided value in the `block`
|
|
167
|
-
* dimension, since we don't yet have any layouts
|
|
168
|
-
* that support virtualization in two dimensions.
|
|
169
|
-
*/
|
|
170
|
-
_calculateScrollIntoViewPosition(i) {
|
|
171
|
-
const { block: t } = i, s = Math.min(this.items.length, Math.max(0, i.index)), e = this._getItemPosition(s)[this._positionDim];
|
|
172
|
-
let h = e;
|
|
173
|
-
if (t !== "start") {
|
|
174
|
-
const o = this._getItemSize(s)[this._sizeDim];
|
|
175
|
-
if (t === "center")
|
|
176
|
-
h = e - 0.5 * this._viewDim1 + 0.5 * o;
|
|
177
|
-
else {
|
|
178
|
-
const l = e - this._viewDim1 + o;
|
|
179
|
-
if (t === "end")
|
|
180
|
-
h = l;
|
|
181
|
-
else {
|
|
182
|
-
const r = this._scrollPosition;
|
|
183
|
-
h = Math.abs(r - e) < Math.abs(r - l) ? e : l;
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
return h += this.offsetWithinScroller[this._positionDim], this._clampScrollPosition(h);
|
|
188
|
-
}
|
|
189
|
-
getScrollIntoViewCoordinates(i) {
|
|
190
|
-
return {
|
|
191
|
-
[this._positionDim]: this._calculateScrollIntoViewPosition(i)
|
|
192
|
-
};
|
|
193
|
-
}
|
|
194
|
-
_sendUnpinnedMessage() {
|
|
195
|
-
this._hostSink({
|
|
196
|
-
type: "unpinned"
|
|
197
|
-
});
|
|
198
|
-
}
|
|
199
|
-
_sendVisibilityChangedMessage() {
|
|
200
|
-
this._hostSink({
|
|
201
|
-
type: "visibilityChanged",
|
|
202
|
-
firstVisible: this._firstVisible,
|
|
203
|
-
lastVisible: this._lastVisible
|
|
204
|
-
});
|
|
205
|
-
}
|
|
206
|
-
_sendStateChangedMessage() {
|
|
207
|
-
const i = /* @__PURE__ */ new Map();
|
|
208
|
-
if (this._first !== -1 && this._last !== -1)
|
|
209
|
-
for (let s = this._first; s <= this._last; s++)
|
|
210
|
-
i.set(s, this._getItemPosition(s));
|
|
211
|
-
const t = {
|
|
212
|
-
type: "stateChanged",
|
|
213
|
-
scrollSize: {
|
|
214
|
-
[this._sizeDim]: this._scrollSize,
|
|
215
|
-
[this._secondarySizeDim]: null
|
|
216
|
-
},
|
|
217
|
-
range: {
|
|
218
|
-
first: this._first,
|
|
219
|
-
last: this._last,
|
|
220
|
-
firstVisible: this._firstVisible,
|
|
221
|
-
lastVisible: this._lastVisible
|
|
222
|
-
},
|
|
223
|
-
childPositions: i
|
|
224
|
-
};
|
|
225
|
-
this._scrollError && (t.scrollError = {
|
|
226
|
-
[this._positionDim]: this._scrollError,
|
|
227
|
-
[this._secondaryPositionDim]: 0
|
|
228
|
-
}, this._scrollError = 0), this._hostSink(t);
|
|
229
|
-
}
|
|
230
|
-
/**
|
|
231
|
-
* Number of items to display.
|
|
232
|
-
*/
|
|
233
|
-
get _num() {
|
|
234
|
-
return this._first === -1 || this._last === -1 ? 0 : this._last - this._first + 1;
|
|
235
|
-
}
|
|
236
|
-
_checkThresholds() {
|
|
237
|
-
if (this._viewDim1 === 0 && this._num > 0 || this._pin !== null)
|
|
238
|
-
this._scheduleReflow();
|
|
239
|
-
else {
|
|
240
|
-
const i = Math.max(0, this._scrollPosition - this._overhang), t = Math.min(this._scrollSize, this._scrollPosition + this._viewDim1 + this._overhang);
|
|
241
|
-
this._physicalMin > i || this._physicalMax < t ? this._scheduleReflow() : this._updateVisibleIndices({ emit: !0 });
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
/**
|
|
245
|
-
* Find the indices of the first and last items to intersect the viewport.
|
|
246
|
-
* Emit a visibleindiceschange event when either index changes.
|
|
247
|
-
*/
|
|
248
|
-
_updateVisibleIndices(i) {
|
|
249
|
-
if (this._first === -1 || this._last === -1)
|
|
250
|
-
return;
|
|
251
|
-
let t = this._first;
|
|
252
|
-
for (; t < this._last && Math.round(this._getItemPosition(t)[this._positionDim] + this._getItemSize(t)[this._sizeDim]) <= Math.round(this._scrollPosition); )
|
|
253
|
-
t++;
|
|
254
|
-
let s = this._last;
|
|
255
|
-
for (; s > this._first && Math.round(this._getItemPosition(s)[this._positionDim]) >= Math.round(this._scrollPosition + this._viewDim1); )
|
|
256
|
-
s--;
|
|
257
|
-
(t !== this._firstVisible || s !== this._lastVisible) && (this._firstVisible = t, this._lastVisible = s, i && i.emit && this._sendVisibilityChangedMessage());
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
function m(n) {
|
|
261
|
-
return n === "horizontal" ? "marginLeft" : "marginTop";
|
|
262
|
-
}
|
|
263
|
-
function u(n) {
|
|
264
|
-
return n === "horizontal" ? "marginRight" : "marginBottom";
|
|
265
|
-
}
|
|
266
|
-
function S(n) {
|
|
267
|
-
return n === "horizontal" ? "xOffset" : "yOffset";
|
|
268
|
-
}
|
|
269
|
-
function z(n, i) {
|
|
270
|
-
const t = [n, i].sort();
|
|
271
|
-
return t[1] <= 0 ? Math.min(...t) : t[0] >= 0 ? Math.max(...t) : t[0] + t[1];
|
|
272
|
-
}
|
|
273
|
-
class p {
|
|
274
|
-
constructor() {
|
|
275
|
-
this._childSizeCache = new g(), this._marginSizeCache = new g(), this._metricsCache = /* @__PURE__ */ new Map();
|
|
276
|
-
}
|
|
277
|
-
update(i, t) {
|
|
278
|
-
const s = /* @__PURE__ */ new Set();
|
|
279
|
-
Object.keys(i).forEach((e) => {
|
|
280
|
-
const h = Number(e);
|
|
281
|
-
this._metricsCache.set(h, i[h]), this._childSizeCache.set(h, i[h][f(t)]), s.add(h), s.add(h + 1);
|
|
282
|
-
});
|
|
283
|
-
for (const e of s) {
|
|
284
|
-
const h = this._metricsCache.get(e)?.[m(t)] || 0, o = this._metricsCache.get(e - 1)?.[u(t)] || 0;
|
|
285
|
-
this._marginSizeCache.set(e, z(h, o));
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
get averageChildSize() {
|
|
289
|
-
return this._childSizeCache.averageSize;
|
|
290
|
-
}
|
|
291
|
-
get totalChildSize() {
|
|
292
|
-
return this._childSizeCache.totalSize;
|
|
293
|
-
}
|
|
294
|
-
get averageMarginSize() {
|
|
295
|
-
return this._marginSizeCache.averageSize;
|
|
296
|
-
}
|
|
297
|
-
get totalMarginSize() {
|
|
298
|
-
return this._marginSizeCache.totalSize;
|
|
299
|
-
}
|
|
300
|
-
getLeadingMarginValue(i, t) {
|
|
301
|
-
return this._metricsCache.get(i)?.[m(t)] || 0;
|
|
302
|
-
}
|
|
303
|
-
getChildSize(i) {
|
|
304
|
-
return this._childSizeCache.getSize(i);
|
|
305
|
-
}
|
|
306
|
-
getMarginSize(i) {
|
|
307
|
-
return this._marginSizeCache.getSize(i);
|
|
308
|
-
}
|
|
309
|
-
clear() {
|
|
310
|
-
this._childSizeCache.clear(), this._marginSizeCache.clear(), this._metricsCache.clear();
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
class M extends d {
|
|
314
|
-
constructor() {
|
|
315
|
-
super(...arguments), this._itemSize = { width: 100, height: 100 }, this._physicalItems = /* @__PURE__ */ new Map(), this._newPhysicalItems = /* @__PURE__ */ new Map(), this._metricsCache = new p(), this._anchorIdx = null, this._anchorPos = null, this._stable = !0, this._measureChildren = !0, this._estimate = !0;
|
|
316
|
-
}
|
|
317
|
-
// protected _defaultConfig: BaseLayoutConfig = Object.assign({}, super._defaultConfig, {
|
|
318
|
-
// })
|
|
319
|
-
// constructor(config: Layout1dConfig) {
|
|
320
|
-
// super(config);
|
|
321
|
-
// }
|
|
322
|
-
get measureChildren() {
|
|
323
|
-
return this._measureChildren;
|
|
324
|
-
}
|
|
325
|
-
/**
|
|
326
|
-
* Determine the average size of all children represented in the sizes
|
|
327
|
-
* argument.
|
|
328
|
-
*/
|
|
329
|
-
updateItemSizes(i) {
|
|
330
|
-
this._metricsCache.update(i, this.direction), this._scheduleReflow();
|
|
331
|
-
}
|
|
332
|
-
/**
|
|
333
|
-
* Set the average item size based on the total length and number of children
|
|
334
|
-
* in range.
|
|
335
|
-
*/
|
|
336
|
-
// _updateItemSize() {
|
|
337
|
-
// // Keep integer values.
|
|
338
|
-
// this._itemSize[this._sizeDim] = this._metricsCache.averageChildSize;
|
|
339
|
-
// }
|
|
340
|
-
_getPhysicalItem(i) {
|
|
341
|
-
return this._newPhysicalItems.get(i) ?? this._physicalItems.get(i);
|
|
342
|
-
}
|
|
343
|
-
_getSize(i) {
|
|
344
|
-
return this._getPhysicalItem(i) && this._metricsCache.getChildSize(i);
|
|
345
|
-
}
|
|
346
|
-
_getAverageSize() {
|
|
347
|
-
return this._metricsCache.averageChildSize || this._itemSize[this._sizeDim];
|
|
348
|
-
}
|
|
349
|
-
_estimatePosition(i) {
|
|
350
|
-
const t = this._metricsCache;
|
|
351
|
-
if (this._first === -1 || this._last === -1)
|
|
352
|
-
return t.averageMarginSize + i * (t.averageMarginSize + this._getAverageSize());
|
|
353
|
-
if (i < this._first) {
|
|
354
|
-
const s = this._first - i;
|
|
355
|
-
return this._getPhysicalItem(this._first).pos - (t.getMarginSize(this._first - 1) || t.averageMarginSize) - (s * t.averageChildSize + (s - 1) * t.averageMarginSize);
|
|
356
|
-
} else {
|
|
357
|
-
const s = i - this._last;
|
|
358
|
-
return this._getPhysicalItem(this._last).pos + (t.getChildSize(this._last) || t.averageChildSize) + (t.getMarginSize(this._last) || t.averageMarginSize) + s * (t.averageChildSize + t.averageMarginSize);
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
/**
|
|
362
|
-
* Returns the position in the scrolling direction of the item at idx.
|
|
363
|
-
* Estimates it if the item at idx is not in the DOM.
|
|
364
|
-
*/
|
|
365
|
-
_getPosition(i) {
|
|
366
|
-
const t = this._getPhysicalItem(i), { averageMarginSize: s } = this._metricsCache;
|
|
367
|
-
return i === 0 ? this._metricsCache.getMarginSize(0) ?? s : t ? t.pos : this._estimatePosition(i);
|
|
368
|
-
}
|
|
369
|
-
_calculateAnchor(i, t) {
|
|
370
|
-
return i <= 0 ? 0 : t > this._scrollSize - this._viewDim1 ? this.items.length - 1 : Math.max(0, Math.min(this.items.length - 1, Math.floor((i + t) / 2 / this._delta)));
|
|
371
|
-
}
|
|
372
|
-
_getAnchor(i, t) {
|
|
373
|
-
if (this._physicalItems.size === 0)
|
|
374
|
-
return this._calculateAnchor(i, t);
|
|
375
|
-
if (this._first < 0)
|
|
376
|
-
return this._calculateAnchor(i, t);
|
|
377
|
-
if (this._last < 0)
|
|
378
|
-
return this._calculateAnchor(i, t);
|
|
379
|
-
const s = this._getPhysicalItem(this._first), e = this._getPhysicalItem(this._last), h = s.pos;
|
|
380
|
-
if (e.pos + this._metricsCache.getChildSize(this._last) < i)
|
|
381
|
-
return this._calculateAnchor(i, t);
|
|
382
|
-
if (h > t)
|
|
383
|
-
return this._calculateAnchor(i, t);
|
|
384
|
-
let r = this._firstVisible - 1, a = -1 / 0;
|
|
385
|
-
for (; a < i; )
|
|
386
|
-
a = this._getPhysicalItem(++r).pos + this._metricsCache.getChildSize(r);
|
|
387
|
-
return r;
|
|
388
|
-
}
|
|
389
|
-
/**
|
|
390
|
-
* Updates _first and _last based on items that should be in the current
|
|
391
|
-
* viewed range.
|
|
392
|
-
*/
|
|
393
|
-
_getActiveItems() {
|
|
394
|
-
this._viewDim1 === 0 || this.items.length === 0 ? this._clearItems() : this._getItems();
|
|
395
|
-
}
|
|
396
|
-
/**
|
|
397
|
-
* Sets the range to empty.
|
|
398
|
-
*/
|
|
399
|
-
_clearItems() {
|
|
400
|
-
this._first = -1, this._last = -1, this._physicalMin = 0, this._physicalMax = 0;
|
|
401
|
-
const i = this._newPhysicalItems;
|
|
402
|
-
this._newPhysicalItems = this._physicalItems, this._newPhysicalItems.clear(), this._physicalItems = i, this._stable = !0;
|
|
403
|
-
}
|
|
404
|
-
/*
|
|
405
|
-
* Updates _first and _last based on items that should be in the given range.
|
|
406
|
-
*/
|
|
407
|
-
_getItems() {
|
|
408
|
-
const i = this._newPhysicalItems;
|
|
409
|
-
this._stable = !0;
|
|
410
|
-
let t, s;
|
|
411
|
-
if (this.pin !== null) {
|
|
412
|
-
const { index: a } = this.pin;
|
|
413
|
-
this._anchorIdx = a, this._anchorPos = this._getPosition(a);
|
|
414
|
-
}
|
|
415
|
-
if (t = this._scrollPosition - this._overhang, s = this._scrollPosition + this._viewDim1 + this._overhang, s < 0 || t > this._scrollSize) {
|
|
416
|
-
this._clearItems();
|
|
417
|
-
return;
|
|
418
|
-
}
|
|
419
|
-
(this._anchorIdx === null || this._anchorPos === null) && (this._anchorIdx = this._getAnchor(t, s), this._anchorPos = this._getPosition(this._anchorIdx));
|
|
420
|
-
let e = this._getSize(this._anchorIdx);
|
|
421
|
-
e === void 0 && (this._stable = !1, e = this._getAverageSize());
|
|
422
|
-
const h = this._metricsCache.getMarginSize(this._anchorIdx) ?? this._metricsCache.averageMarginSize, o = this._metricsCache.getMarginSize(this._anchorIdx + 1) ?? this._metricsCache.averageMarginSize;
|
|
423
|
-
this._anchorIdx === 0 && (this._anchorPos = h), this._anchorIdx === this.items.length - 1 && (this._anchorPos = this._scrollSize - o - e);
|
|
424
|
-
let l = 0;
|
|
425
|
-
for (this._anchorPos + e + o < t && (l = t - (this._anchorPos + e + o)), this._anchorPos - h > s && (l = s - (this._anchorPos - h)), l && (this._scrollPosition -= l, t -= l, s -= l, this._scrollError += l), i.set(this._anchorIdx, { pos: this._anchorPos, size: e }), this._first = this._last = this._anchorIdx, this._physicalMin = this._anchorPos - h, this._physicalMax = this._anchorPos + e + o; this._physicalMin > t && this._first > 0; ) {
|
|
426
|
-
let a = this._getSize(--this._first);
|
|
427
|
-
a === void 0 && (this._stable = !1, a = this._getAverageSize());
|
|
428
|
-
let _ = this._metricsCache.getMarginSize(this._first);
|
|
429
|
-
_ === void 0 && (this._stable = !1, _ = this._metricsCache.averageMarginSize), this._physicalMin -= a;
|
|
430
|
-
const c = this._physicalMin;
|
|
431
|
-
if (i.set(this._first, { pos: c, size: a }), this._physicalMin -= _, this._stable === !1 && this._estimate === !1)
|
|
432
|
-
break;
|
|
433
|
-
}
|
|
434
|
-
for (; this._physicalMax < s && this._last < this.items.length - 1; ) {
|
|
435
|
-
let a = this._getSize(++this._last);
|
|
436
|
-
a === void 0 && (this._stable = !1, a = this._getAverageSize());
|
|
437
|
-
let _ = this._metricsCache.getMarginSize(this._last);
|
|
438
|
-
_ === void 0 && (this._stable = !1, _ = this._metricsCache.averageMarginSize);
|
|
439
|
-
const c = this._physicalMax;
|
|
440
|
-
if (i.set(this._last, { pos: c, size: a }), this._physicalMax += a + _, !this._stable && !this._estimate)
|
|
441
|
-
break;
|
|
442
|
-
}
|
|
443
|
-
const r = this._calculateError();
|
|
444
|
-
r && (this._physicalMin -= r, this._physicalMax -= r, this._anchorPos -= r, this._scrollPosition -= r, i.forEach((a) => a.pos -= r), this._scrollError += r), this._stable && (this._newPhysicalItems = this._physicalItems, this._newPhysicalItems.clear(), this._physicalItems = i);
|
|
445
|
-
}
|
|
446
|
-
_calculateError() {
|
|
447
|
-
return this._first === 0 ? this._physicalMin : this._physicalMin <= 0 ? this._physicalMin - this._first * this._delta : this._last === this.items.length - 1 ? this._physicalMax - this._scrollSize : this._physicalMax >= this._scrollSize ? this._physicalMax - this._scrollSize + (this.items.length - 1 - this._last) * this._delta : 0;
|
|
448
|
-
}
|
|
449
|
-
_reflow() {
|
|
450
|
-
const { _first: i, _last: t } = this;
|
|
451
|
-
super._reflow(), (this._first === -1 && this._last == -1 || this._first === i && this._last === t) && this._resetReflowState();
|
|
452
|
-
}
|
|
453
|
-
_resetReflowState() {
|
|
454
|
-
this._anchorIdx = null, this._anchorPos = null, this._stable = !0;
|
|
455
|
-
}
|
|
456
|
-
_updateScrollSize() {
|
|
457
|
-
const { averageMarginSize: i } = this._metricsCache;
|
|
458
|
-
this._scrollSize = Math.max(1, this.items.length * (i + this._getAverageSize()) + i);
|
|
459
|
-
}
|
|
460
|
-
/**
|
|
461
|
-
* Returns the average size (precise or estimated) of an item in the scrolling direction,
|
|
462
|
-
* including any surrounding space.
|
|
463
|
-
*/
|
|
464
|
-
get _delta() {
|
|
465
|
-
const { averageMarginSize: i } = this._metricsCache;
|
|
466
|
-
return this._getAverageSize() + i;
|
|
467
|
-
}
|
|
468
|
-
/**
|
|
469
|
-
* Returns the top and left positioning of the item at idx.
|
|
470
|
-
*/
|
|
471
|
-
_getItemPosition(i) {
|
|
472
|
-
return {
|
|
473
|
-
[this._positionDim]: this._getPosition(i),
|
|
474
|
-
[this._secondaryPositionDim]: 0,
|
|
475
|
-
[S(this.direction)]: -(this._metricsCache.getLeadingMarginValue(i, this.direction) ?? this._metricsCache.averageMarginSize)
|
|
476
|
-
};
|
|
477
|
-
}
|
|
478
|
-
/**
|
|
479
|
-
* Returns the height and width of the item at idx.
|
|
480
|
-
*/
|
|
481
|
-
_getItemSize(i) {
|
|
482
|
-
return {
|
|
483
|
-
[this._sizeDim]: this._getSize(i) || this._getAverageSize(),
|
|
484
|
-
[this._secondarySizeDim]: this._itemSize[this._secondarySizeDim]
|
|
485
|
-
};
|
|
486
|
-
}
|
|
487
|
-
_viewDim2Changed() {
|
|
488
|
-
this._metricsCache.clear(), this._scheduleReflow();
|
|
489
|
-
}
|
|
490
|
-
}
|
|
491
|
-
export {
|
|
492
|
-
M as FlowLayout
|
|
493
|
-
};
|