({
start,
end,
deferredStart,
deferredEnd,
pendingDelta,
isSticky,
brokeSticky = false,
isRangeSettling = false,
offsets,
viewportHeight,
listOrigin,
itemCount,
scrollTop,
maxMountedItems = MAX_MOUNTED_ITEMS,
}: VirtualScrollRenderPolicyInput)
| 342 | } |
| 343 | |
| 344 | export function computeVirtualScrollRenderPolicy({ |
| 345 | start, |
| 346 | end, |
| 347 | deferredStart, |
| 348 | deferredEnd, |
| 349 | pendingDelta, |
| 350 | isSticky, |
| 351 | brokeSticky = false, |
| 352 | isRangeSettling = false, |
| 353 | offsets, |
| 354 | viewportHeight, |
| 355 | listOrigin, |
| 356 | itemCount, |
| 357 | scrollTop, |
| 358 | maxMountedItems = MAX_MOUNTED_ITEMS, |
| 359 | }: VirtualScrollRenderPolicyInput): VirtualScrollRenderPolicy { |
| 360 | let effStart = start < deferredStart ? deferredStart : start |
| 361 | let effEnd = end > deferredEnd ? deferredEnd : end |
| 362 | |
| 363 | if (effStart > effEnd || isSticky || brokeSticky) { |
| 364 | effStart = start |
| 365 | effEnd = end |
| 366 | } |
| 367 | |
| 368 | if (pendingDelta > 0) { |
| 369 | effEnd = end |
| 370 | } |
| 371 | |
| 372 | if (effEnd - effStart > maxMountedItems) { |
| 373 | const mid = (offsets[effStart]! + offsets[effEnd]!) / 2 |
| 374 | if (scrollTop - listOrigin < mid) { |
| 375 | effEnd = effStart + maxMountedItems |
| 376 | } else { |
| 377 | effStart = effEnd - maxMountedItems |
| 378 | } |
| 379 | } |
| 380 | |
| 381 | const clampEnabled = |
| 382 | !isSticky && !isRangeSettling && viewportHeight > 0 && scrollTop >= 0 |
| 383 | |
| 384 | return { |
| 385 | range: [effStart, effEnd], |
| 386 | clampEnabled, |
| 387 | } |
| 388 | } |
| 389 | |
| 390 | export function computeVirtualScrollClampBounds({ |
| 391 | clampEnabled, |
no outgoing calls
no test coverage detected