@tanstack%2Fvirtual-core@3.17.0.patch 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. diff --git a/dist/cjs/index.cjs b/dist/cjs/index.cjs
  2. index df75d0cf0347b62906e04e454d4f4ef062ed5c48..e5110715b049c6c8b992bd1375a7432df7c0182e 100644
  3. --- a/dist/cjs/index.cjs
  4. +++ b/dist/cjs/index.cjs
  5. @@ -526,6 +526,7 @@ class Virtualizer {
  6. this.scrollOffset = this.scrollOffset ?? (typeof this.options.initialOffset === "function" ? this.options.initialOffset() : this.options.initialOffset);
  7. return this.scrollOffset;
  8. };
  9. + this.getLogicalScrollOffset = () => this.getScrollOffset() + this.scrollAdjustments;
  10. this.getFurthestMeasurement = (measurements, index) => {
  11. const furthestMeasurementsFound = /* @__PURE__ */ new Map();
  12. const furthestMeasurements = /* @__PURE__ */ new Map();
  13. @@ -715,10 +716,12 @@ class Virtualizer {
  14. this.options.lanes
  15. ],
  16. (measurements, outerSize, scrollOffset, lanes) => {
  17. + const maxScrollOffset = Math.max(this.getTotalSize() - outerSize, 0);
  18. + const effectiveScrollOffset = Math.min(Math.max(scrollOffset, 0), maxScrollOffset);
  19. return this.range = measurements.length > 0 && outerSize > 0 ? calculateRange({
  20. measurements,
  21. outerSize,
  22. - scrollOffset,
  23. + scrollOffset: effectiveScrollOffset,
  24. lanes,
  25. // Pass the typed array so binary search + forward-walk can
  26. // read start/end directly from Float64Array, skipping the
  27. diff --git a/dist/cjs/index.d.cts b/dist/cjs/index.d.cts
  28. index c61ee17752565253f795c7fc7d57e86237ecbb52..705bb7e3a121b040fb1a3e7890179eaa3e9b219e 100644
  29. --- a/dist/cjs/index.d.cts
  30. +++ b/dist/cjs/index.d.cts
  31. @@ -108,6 +108,7 @@ export declare class Virtualizer<TScrollElement extends Element | Window, TItemE
  32. scrollRect: Rect | null;
  33. scrollOffset: number | null;
  34. scrollDirection: ScrollDirection | null;
  35. + getLogicalScrollOffset: () => number;
  36. private scrollAdjustments;
  37. private _iosDeferredAdjustment;
  38. private _iosTouching;
  39. diff --git a/dist/esm/index.d.ts b/dist/esm/index.d.ts
  40. index b03abab604eb6578f6f56ff92c489259cfaf8f19..0495f372ea000dffc416c4f56809946f7ba73099 100644
  41. --- a/dist/esm/index.d.ts
  42. +++ b/dist/esm/index.d.ts
  43. @@ -108,6 +108,7 @@ export declare class Virtualizer<TScrollElement extends Element | Window, TItemE
  44. scrollRect: Rect | null;
  45. scrollOffset: number | null;
  46. scrollDirection: ScrollDirection | null;
  47. + getLogicalScrollOffset: () => number;
  48. private scrollAdjustments;
  49. private _iosDeferredAdjustment;
  50. private _iosTouching;
  51. diff --git a/dist/esm/index.js b/dist/esm/index.js
  52. index e384cf7541978a2782b9dca68146e869b16ac3f2..77af22006325377bf9ca0052a3554f881f9e75fe 100644
  53. --- a/dist/esm/index.js
  54. +++ b/dist/esm/index.js
  55. @@ -524,6 +524,7 @@ class Virtualizer {
  56. this.scrollOffset = this.scrollOffset ?? (typeof this.options.initialOffset === "function" ? this.options.initialOffset() : this.options.initialOffset);
  57. return this.scrollOffset;
  58. };
  59. + this.getLogicalScrollOffset = () => this.getScrollOffset() + this.scrollAdjustments;
  60. this.getFurthestMeasurement = (measurements, index) => {
  61. const furthestMeasurementsFound = /* @__PURE__ */ new Map();
  62. const furthestMeasurements = /* @__PURE__ */ new Map();
  63. @@ -713,10 +714,12 @@ class Virtualizer {
  64. this.options.lanes
  65. ],
  66. (measurements, outerSize, scrollOffset, lanes) => {
  67. + const maxScrollOffset = Math.max(this.getTotalSize() - outerSize, 0);
  68. + const effectiveScrollOffset = Math.min(Math.max(scrollOffset, 0), maxScrollOffset);
  69. return this.range = measurements.length > 0 && outerSize > 0 ? calculateRange({
  70. measurements,
  71. outerSize,
  72. - scrollOffset,
  73. + scrollOffset: effectiveScrollOffset,
  74. lanes,
  75. // Pass the typed array so binary search + forward-walk can
  76. // read start/end directly from Float64Array, skipping the
  77. diff --git a/src/index.ts b/src/index.ts
  78. index d35b3e0695a9c85b261bc1a4fbe23c0a60d5b204..c504e630a60a3a7791345622bb02754b1308fd86 100644
  79. --- a/src/index.ts
  80. +++ b/src/index.ts
  81. @@ -1047,6 +1047,8 @@ export class Virtualizer<
  82. return this.scrollOffset
  83. }
  84. + getLogicalScrollOffset = () => this.getScrollOffset() + this.scrollAdjustments
  85. +
  86. private getFurthestMeasurement = (
  87. measurements: Array<VirtualItem>,
  88. index: number,
  89. @@ -1334,12 +1336,14 @@ export class Virtualizer<
  90. this.options.lanes,
  91. ],
  92. (measurements, outerSize, scrollOffset, lanes) => {
  93. + const maxScrollOffset = Math.max(this.getTotalSize() - outerSize, 0)
  94. + const effectiveScrollOffset = Math.min(Math.max(scrollOffset, 0), maxScrollOffset)
  95. return (this.range =
  96. measurements.length > 0 && outerSize > 0
  97. ? calculateRange({
  98. measurements,
  99. outerSize,
  100. - scrollOffset,
  101. + scrollOffset: effectiveScrollOffset,
  102. lanes,
  103. // Pass the typed array so binary search + forward-walk can
  104. // read start/end directly from Float64Array, skipping the