@tanstack%2Fvirtual-core@3.17.3.patch 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. diff --git a/dist/cjs/index.cjs b/dist/cjs/index.cjs
  2. index 52ae6ca12f8d1c650ee7f1bd55573ee7d4f8b65f..830f646f5bd80f4e00f442291ad6e4c6c508630d 100644
  3. --- a/dist/cjs/index.cjs
  4. +++ b/dist/cjs/index.cjs
  5. @@ -716,17 +716,20 @@ class Virtualizer {
  6. this.getMeasurements(),
  7. this.getSize(),
  8. this.getScrollOffset(),
  9. - this.options.lanes
  10. + this.options.lanes,
  11. + this.options.paddingEnd
  12. ],
  13. - (measurements, outerSize, scrollOffset, lanes) => {
  14. + (measurements, outerSize, scrollOffset, lanes, _paddingEnd) => {
  15. if (measurements.length === 0 || outerSize === 0) {
  16. this.range = null;
  17. return null;
  18. }
  19. + const maxScrollOffset = Math.max(this.options.scrollMargin + this.getTotalSize() - outerSize, 0);
  20. + const effectiveScrollOffset = Math.min(Math.max(scrollOffset, 0), maxScrollOffset);
  21. this.range = calculateRangeImpl(
  22. measurements,
  23. outerSize,
  24. - scrollOffset,
  25. + effectiveScrollOffset,
  26. lanes,
  27. // Pass the typed array so binary search + forward-walk can read
  28. // start/end directly from Float64Array, skipping the Proxy traps.
  29. diff --git a/dist/cjs/index.d.cts b/dist/cjs/index.d.cts
  30. index c61ee17752565253f795c7fc7d57e86237ecbb52..430c622a18c69407df9f1ca82ee9440e9be287b7 100644
  31. --- a/dist/cjs/index.d.cts
  32. +++ b/dist/cjs/index.d.cts
  33. @@ -144,7 +144,7 @@ export declare class Virtualizer<TScrollElement extends Element | Window, TItemE
  34. startIndex: number;
  35. endIndex: number;
  36. } | null;
  37. - updateDeps(newDeps: [VirtualItem[], number, number, number]): void;
  38. + updateDeps(newDeps: [VirtualItem[], number, number, number, number]): void;
  39. };
  40. getVirtualIndexes: {
  41. (): number[];
  42. diff --git a/dist/esm/index.d.ts b/dist/esm/index.d.ts
  43. index b03abab604eb6578f6f56ff92c489259cfaf8f19..940310f9215ba5bf666c5b71e92dddbbbc85635d 100644
  44. --- a/dist/esm/index.d.ts
  45. +++ b/dist/esm/index.d.ts
  46. @@ -144,7 +144,7 @@ export declare class Virtualizer<TScrollElement extends Element | Window, TItemE
  47. startIndex: number;
  48. endIndex: number;
  49. } | null;
  50. - updateDeps(newDeps: [VirtualItem[], number, number, number]): void;
  51. + updateDeps(newDeps: [VirtualItem[], number, number, number, number]): void;
  52. };
  53. getVirtualIndexes: {
  54. (): number[];
  55. diff --git a/dist/esm/index.js b/dist/esm/index.js
  56. index 3032c0ca457582be3f47923cba1f7d92c848745c..6e52124048fb3bc7b7ee37e763354b33593a6285 100644
  57. --- a/dist/esm/index.js
  58. +++ b/dist/esm/index.js
  59. @@ -714,17 +714,20 @@ class Virtualizer {
  60. this.getMeasurements(),
  61. this.getSize(),
  62. this.getScrollOffset(),
  63. - this.options.lanes
  64. + this.options.lanes,
  65. + this.options.paddingEnd
  66. ],
  67. - (measurements, outerSize, scrollOffset, lanes) => {
  68. + (measurements, outerSize, scrollOffset, lanes, _paddingEnd) => {
  69. if (measurements.length === 0 || outerSize === 0) {
  70. this.range = null;
  71. return null;
  72. }
  73. + const maxScrollOffset = Math.max(this.options.scrollMargin + this.getTotalSize() - outerSize, 0);
  74. + const effectiveScrollOffset = Math.min(Math.max(scrollOffset, 0), maxScrollOffset);
  75. this.range = calculateRangeImpl(
  76. measurements,
  77. outerSize,
  78. - scrollOffset,
  79. + effectiveScrollOffset,
  80. lanes,
  81. // Pass the typed array so binary search + forward-walk can read
  82. // start/end directly from Float64Array, skipping the Proxy traps.
  83. diff --git a/src/index.ts b/src/index.ts
  84. index 7ad79aacd591c3a4f7855c91b2727a59a9579bca..201406779ee85d2f2e5b01a8ea284aa9a5f694e2 100644
  85. --- a/src/index.ts
  86. +++ b/src/index.ts
  87. @@ -1367,16 +1367,19 @@ export class Virtualizer<
  88. this.getSize(),
  89. this.getScrollOffset(),
  90. this.options.lanes,
  91. + this.options.paddingEnd,
  92. ],
  93. - (measurements, outerSize, scrollOffset, lanes) => {
  94. + (measurements, outerSize, scrollOffset, lanes, _paddingEnd) => {
  95. if (measurements.length === 0 || outerSize === 0) {
  96. this.range = null
  97. return null
  98. }
  99. + const maxScrollOffset = Math.max(this.options.scrollMargin + this.getTotalSize() - outerSize, 0)
  100. + const effectiveScrollOffset = Math.min(Math.max(scrollOffset, 0), maxScrollOffset)
  101. this.range = calculateRangeImpl(
  102. measurements,
  103. outerSize,
  104. - scrollOffset,
  105. + effectiveScrollOffset,
  106. lanes,
  107. // Pass the typed array so binary search + forward-walk can read
  108. // start/end directly from Float64Array, skipping the Proxy traps.