@omnigrid/core 0.1.19 → 0.1.20
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/dist/types.d.ts +1 -0
- package/dist/virtualizer.js +6 -6
- package/package.json +1 -1
package/dist/types.d.ts
CHANGED
|
@@ -310,6 +310,7 @@ export interface GridOptions<T> {
|
|
|
310
310
|
/** Row data; omitted or null means an initial load is pending. */
|
|
311
311
|
data?: T[] | null;
|
|
312
312
|
columns: ColumnDef<T>[];
|
|
313
|
+
/** Returns a stable row ID; defaults to the row's current index. Use a stable ID to preserve row identity when rows are reordered. */
|
|
313
314
|
getRowId?: (row: T, index: number) => RowId;
|
|
314
315
|
rowHeight?: number;
|
|
315
316
|
/** Rows to render beyond the visible viewport (top + bottom buffer). @default 5 */
|
package/dist/virtualizer.js
CHANGED
|
@@ -107,14 +107,14 @@ export class Virtualizer {
|
|
|
107
107
|
};
|
|
108
108
|
}
|
|
109
109
|
getColumnWidths(columns, viewportWidth) {
|
|
110
|
-
//
|
|
111
|
-
//
|
|
112
|
-
//
|
|
113
|
-
// for the three column partitions (pinnedLeft, scrollable, pinnedRight).
|
|
110
|
+
// Column objects are stable across scroll frames, so validate each
|
|
111
|
+
// identity before reusing cached widths. Checking only the first column
|
|
112
|
+
// misses updates to other columns when setColumns replaces them.
|
|
114
113
|
if (columns.length > 0) {
|
|
115
114
|
const cacheKey = columns[0];
|
|
116
115
|
const cached = this.widthsCache.get(cacheKey);
|
|
117
|
-
|
|
116
|
+
const columnsUnchanged = cached?.columns.length === columns.length && cached.columns.every((column, index) => column === columns[index]);
|
|
117
|
+
if (cached && cached.viewportWidth === viewportWidth && columnsUnchanged) {
|
|
118
118
|
return cached.widths;
|
|
119
119
|
}
|
|
120
120
|
}
|
|
@@ -150,7 +150,7 @@ export class Virtualizer {
|
|
|
150
150
|
}
|
|
151
151
|
const result = this.quantizeWidths(widths);
|
|
152
152
|
if (columns.length > 0) {
|
|
153
|
-
this.widthsCache.set(columns[0], { viewportWidth,
|
|
153
|
+
this.widthsCache.set(columns[0], { viewportWidth, columns: [...columns], widths: result });
|
|
154
154
|
}
|
|
155
155
|
return result;
|
|
156
156
|
}
|