virtua 0.52.2 → 0.52.3

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.
@@ -526,17 +526,7 @@ var updateGridAxis = (store, layout, axis, size, header, footer, mutable) => {
526
526
  }
527
527
  };
528
528
  var rowStatesCache = /*#__PURE__*/ new WeakMap();
529
- var hasTrackIn = (extras, from, to, pinnedStart, start, end, trailStart) => {
530
- if (from < pinnedStart || max(from, start) < min(to, end + 1) || trailStart < to) {
531
- return true;
532
- }
533
- for (const i of extras) {
534
- if (i >= from && i < to) {
535
- return true;
536
- }
537
- }
538
- return false;
539
- };
529
+ var hasVisibleTrack = (from, to, pinnedStart, start, end, trailStart) => from < pinnedStart || max(from, start) < min(to, end + 1) || trailStart < to;
540
530
  var getSectionStarts = (sectionRows, pinnedStart, trailStart) => {
541
531
  const starts = [];
542
532
  for (const rowIndex of sectionRows) {
@@ -562,12 +552,6 @@ var getSectionIndex = (starts, rowIndex, trailStart) => {
562
552
  }
563
553
  return lo - 1;
564
554
  };
565
- var addSectionHeader = (extras, sectionStarts, rowIndex, trailStart) => {
566
- const section = getSectionIndex(sectionStarts, rowIndex, trailStart);
567
- if (section >= 0) {
568
- extras.push(sectionStarts[section]);
569
- }
570
- };
571
555
  var addExtras = (indexes, extras, e, bound, lastRendered) => {
572
556
  const extrasLength = extras.length;
573
557
  for (; e < extrasLength && extras[e] < bound; e++) {
@@ -652,42 +636,37 @@ var createGridPlan = (rowLayout, colLayout, rowRange, colRange, sectionRows = EM
652
636
  extraCells.push(cell);
653
637
  }
654
638
  }
639
+ const keptLength = extraCells.length;
655
640
  const sectionLength = sectionStarts.length;
656
- if (sectionLength) {
657
- addSectionHeader(extraRows, sectionStarts, rowRangeStart, rowTrailStart);
658
- extraCols.push(rowHeaderCol);
641
+ const firstSection = getSectionIndex(sectionStarts, rowRangeStart, rowTrailStart);
642
+ const firstSectionStart = firstSection < 0 ? -1 : sectionStarts[firstSection];
643
+ if (firstSectionStart >= 0) {
644
+ extraRows.push(firstSectionStart);
659
645
  }
660
- let waiting = spans;
661
- let l = 0;
662
- do {
663
- for (; l < extraCells.length; l++) {
664
- const { rowIndex, colIndex } = extraCells[l];
665
- extraRows.push(rowIndex);
666
- addSectionHeader(extraRows, sectionStarts, rowIndex, rowTrailStart);
667
- extraCols.push(colIndex);
668
- }
669
- const rest = [];
670
- for (const span of waiting) {
671
- const row = span.rowIndex;
672
- const col = span.colIndex;
673
- const rowTo = getSpanRowEnd(span, totalRowCount);
674
- const colTo = getSpanColEnd(span, totalColCount);
675
- if (row < totalRowCount && col < totalColCount && (rowTo - row > 1 || colTo - col > 1)) {
676
- const hasRenderedRow = hasTrackIn(extraRows, row, rowTo, rowPinnedStart, rowRangeStart, rowRangeEnd, rowTrailStart);
677
- if (hasRenderedRow && hasTrackIn(extraCols, col, colTo, colPinnedStart, colRangeStart, colRangeEnd, colTrailStart)) {
678
- extraCells.push(span);
679
- } else if (hasRenderedRow) {
680
- const section = getSectionIndex(sectionStarts, rowTo - 1, rowTrailStart);
681
- if (row < rowPinnedStart || section >= 0 && sectionStarts[section] >= row) {
682
- rest.push(span);
683
- }
684
- } else if (col < colPinnedStart) {
685
- rest.push(span);
686
- }
646
+ for (const span of spans) {
647
+ const row = span.rowIndex;
648
+ const col = span.colIndex;
649
+ const rowTo = getSpanRowEnd(span, totalRowCount);
650
+ const colTo = getSpanColEnd(span, totalColCount);
651
+ if (row < totalRowCount && col < totalColCount && (rowTo - row > 1 || colTo - col > 1)) {
652
+ let isLaid = (hasVisibleTrack(row, rowTo, rowPinnedStart, rowRangeStart, rowRangeEnd, rowTrailStart) || firstSectionStart >= row && firstSectionStart < rowTo) && hasVisibleTrack(col, colTo, colPinnedStart, colRangeStart, colRangeEnd, colTrailStart);
653
+ for (let k = 0; !isLaid && k < keptLength; k++) {
654
+ const { rowIndex, colIndex } = extraCells[k];
655
+ isLaid = rowIndex >= row && rowIndex < rowTo && colIndex >= col && colIndex < colTo;
656
+ }
657
+ if (isLaid) {
658
+ extraCells.push(span);
687
659
  }
688
660
  }
689
- waiting = rest;
690
- } while (l < extraCells.length);
661
+ }
662
+ for (const { rowIndex, colIndex } of extraCells) {
663
+ const section = getSectionIndex(sectionStarts, rowIndex, rowTrailStart);
664
+ extraRows.push(rowIndex);
665
+ if (section >= 0) {
666
+ extraRows.push(sectionStarts[section]);
667
+ }
668
+ extraCols.push(colIndex);
669
+ }
691
670
  sort(extraRows);
692
671
  sort(extraCols);
693
672
  const rows = getTrackIndexes(extraRows, totalRowCount, rowPinnedStart, rowRangeStart, rowRangeEnd, rowTrailStart);
@@ -723,7 +702,6 @@ var createGridPlan = (rowLayout, colLayout, rowRange, colRange, sectionRows = EM
723
702
  for (const rowIndex of rows) {
724
703
  const isRowPinnedStart = rowIndex < rowPinnedStart;
725
704
  const isRowPinnedEnd = rowIndex >= rowTrailStart;
726
- const isRowInRangeOrPinnedToEnd = isRowPinnedEnd || rowIndex >= rowRangeStart && rowIndex <= rowRangeEnd;
727
705
  const section = getSectionIndex(sectionStarts, rowIndex, rowTrailStart);
728
706
  const groupStart = isRowPinnedStart ? 0 : isRowPinnedEnd ? rowTrailStart : section < 0 ? -1 : sectionStarts[section];
729
707
  if (rowIndex === groupStart) {
@@ -740,6 +718,7 @@ var createGridPlan = (rowLayout, colLayout, rowRange, colRange, sectionRows = EM
740
718
  groupRows = groups;
741
719
  }
742
720
  const isSectionHeaderRow = section >= 0 && rowIndex === groupStart;
721
+ const isRowVisible = isRowPinnedStart || isRowPinnedEnd || rowIndex === firstSectionStart || rowIndex >= rowRangeStart && rowIndex <= rowRangeEnd;
743
722
  const rowTop = isSectionHeaderRow ? sectionHeaderTop : null;
744
723
  const rowKey = rowIndex * totalColCount;
745
724
  const prevRow = prev && prev.get(rowIndex);
@@ -753,9 +732,9 @@ var createGridPlan = (rowLayout, colLayout, rowRange, colRange, sectionRows = EM
753
732
  const colIndex = cols[i];
754
733
  const isColPinnedStart = colIndex < colPinnedStart;
755
734
  const isColPinnedEnd = colIndex >= colTrailStart;
756
- const isColInRangeOrPinnedToEnd = isColPinnedEnd || colIndex >= colRangeStart && colIndex <= colRangeEnd;
735
+ const isColVisible = isColPinnedStart || isColPinnedEnd || colIndex >= colRangeStart && colIndex <= colRangeEnd;
757
736
  const span = spanCells.get(rowKey + colIndex);
758
- if (span ? span.rowIndex === rowIndex && span.colIndex === colIndex : isRowInRangeOrPinnedToEnd && isColInRangeOrPinnedToEnd || isRowPinnedStart || isSectionHeaderRow || isColPinnedStart) {
737
+ if (span ? span.rowIndex === rowIndex && span.colIndex === colIndex : isRowVisible && isColVisible) {
759
738
  const rowTo = span ? getSpanRowEnd(span, totalRowCount) : rowIndex + 1;
760
739
  const colTo = span ? getSpanColEnd(span, totalColCount) : colIndex + 1;
761
740
  const rowSpan = rowTo - rowIndex;
@@ -1319,7 +1298,7 @@ var scrollGridAxisToIndex = (driver, store, layout, sections, index, align, isHo
1319
1298
  const starts = getSectionStarts(sections, pinnedStart, trailStart);
1320
1299
  const section = getSectionIndex(starts, index, trailStart);
1321
1300
  const sectionHeader = section < 0 ? -1 : starts[section];
1322
- const getInsetStart = () => layout.$getItemOffset(pinnedStart) + (sectionHeader < 0 || sectionHeader === index ? 0 : store.$getItemOffset(sectionHeader + 1) - store.$getItemOffset(sectionHeader));
1301
+ const getInsetStart = () => layout.$getItemOffset(pinnedStart) + (sectionHeader < 0 || sectionHeader === index ? 0 : layout.$getItemOffset(sectionHeader + 1) - layout.$getItemOffset(sectionHeader));
1323
1302
  const getInsetEnd = () => layout.$getItemOffset(count) - layout.$getItemOffset(trailStart);
1324
1303
  if (align === "nearest") {
1325
1304
  if (index < pinnedStart || index >= trailStart) {