virtua 0.45.0 → 0.45.1

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.
@@ -968,9 +968,9 @@ const createWindowScroller = (store, isHorizontal) => {
968
968
  /**
969
969
  * @internal
970
970
  */
971
- const createGridScroller = (vStore, hStore) => {
972
- const vScroller = createScroller(vStore, false);
973
- const hScroller = createScroller(hStore, true);
971
+ const createGridScroller = (rowStore, colStore) => {
972
+ const vScroller = createScroller(rowStore, false);
973
+ const hScroller = createScroller(colStore, true);
974
974
  return {
975
975
  $observe(viewportElement) {
976
976
  vScroller.$observe(viewportElement);
@@ -1111,10 +1111,8 @@ const createWindowResizer = (store, isHorizontal) => {
1111
1111
  /**
1112
1112
  * @internal
1113
1113
  */
1114
- const createGridResizer = (vStore, hStore) => {
1114
+ const createGridResizer = (rowStore, colStore) => {
1115
1115
  let viewportElement;
1116
- const heightKey = "height";
1117
- const widthKey = "width";
1118
1116
  const mountedIndexes = new WeakMap();
1119
1117
  const maybeCachedRowIndexes = new Set();
1120
1118
  const maybeCachedColIndexes = new Set();
@@ -1123,13 +1121,13 @@ const createGridResizer = (vStore, hStore) => {
1123
1121
  const resizeObserver = createResizeObserver((entries) => {
1124
1122
  const resizedRows = new Set();
1125
1123
  const resizedCols = new Set();
1126
- for (const { target, contentRect } of entries) {
1124
+ for (const { target, contentRect: { width, height }, } of entries) {
1127
1125
  // Skip zero-sized rects that may be observed under `display: none` style
1128
1126
  if (!target.offsetParent)
1129
1127
  continue;
1130
1128
  if (target === viewportElement) {
1131
- vStore.$update(ACTION_VIEWPORT_RESIZE, contentRect[heightKey]);
1132
- hStore.$update(ACTION_VIEWPORT_RESIZE, contentRect[widthKey]);
1129
+ rowStore.$update(ACTION_VIEWPORT_RESIZE, height);
1130
+ colStore.$update(ACTION_VIEWPORT_RESIZE, width);
1133
1131
  }
1134
1132
  else {
1135
1133
  const cell = mountedIndexes.get(target);
@@ -1137,20 +1135,16 @@ const createGridResizer = (vStore, hStore) => {
1137
1135
  const [rowIndex, colIndex] = cell;
1138
1136
  const key = getKey(rowIndex, colIndex);
1139
1137
  const prevSize = sizeCache.get(key);
1140
- const size = [
1141
- contentRect[heightKey],
1142
- contentRect[widthKey],
1143
- ];
1144
1138
  let rowResized;
1145
1139
  let colResized;
1146
1140
  if (!prevSize) {
1147
1141
  rowResized = colResized = true;
1148
1142
  }
1149
1143
  else {
1150
- if (prevSize[0] !== size[0]) {
1144
+ if (prevSize[0] !== height) {
1151
1145
  rowResized = true;
1152
1146
  }
1153
- if (prevSize[1] !== size[1]) {
1147
+ if (prevSize[1] !== width) {
1154
1148
  colResized = true;
1155
1149
  }
1156
1150
  }
@@ -1161,7 +1155,7 @@ const createGridResizer = (vStore, hStore) => {
1161
1155
  resizedCols.add(colIndex);
1162
1156
  }
1163
1157
  if (rowResized || colResized) {
1164
- sizeCache.set(key, size);
1158
+ sizeCache.set(key, [height, width]);
1165
1159
  }
1166
1160
  }
1167
1161
  }
@@ -1180,7 +1174,7 @@ const createGridResizer = (vStore, hStore) => {
1180
1174
  heightResizes.push([rowIndex, maxHeight]);
1181
1175
  }
1182
1176
  });
1183
- vStore.$update(ACTION_ITEM_RESIZE, heightResizes);
1177
+ rowStore.$update(ACTION_ITEM_RESIZE, heightResizes);
1184
1178
  }
1185
1179
  if (resizedCols.size) {
1186
1180
  const widthResizes = [];
@@ -1196,7 +1190,7 @@ const createGridResizer = (vStore, hStore) => {
1196
1190
  widthResizes.push([colIndex, maxWidth]);
1197
1191
  }
1198
1192
  });
1199
- hStore.$update(ACTION_ITEM_RESIZE, widthResizes);
1193
+ colStore.$update(ACTION_ITEM_RESIZE, widthResizes);
1200
1194
  }
1201
1195
  });
1202
1196
  return {
@@ -1215,19 +1209,19 @@ const createGridResizer = (vStore, hStore) => {
1215
1209
  },
1216
1210
  $resizeCols(cols) {
1217
1211
  for (const [c] of cols) {
1218
- for (let r = 0; r < vStore.$getItemsLength(); r++) {
1212
+ for (let r = 0; r < rowStore.$getItemsLength(); r++) {
1219
1213
  sizeCache.delete(getKey(r, c));
1220
1214
  }
1221
1215
  }
1222
- hStore.$update(ACTION_ITEM_RESIZE, cols);
1216
+ colStore.$update(ACTION_ITEM_RESIZE, cols);
1223
1217
  },
1224
1218
  $resizeRows(rows) {
1225
1219
  for (const [r] of rows) {
1226
- for (let c = 0; c < hStore.$getItemsLength(); c++) {
1220
+ for (let c = 0; c < colStore.$getItemsLength(); c++) {
1227
1221
  sizeCache.delete(getKey(r, c));
1228
1222
  }
1229
1223
  }
1230
- vStore.$update(ACTION_ITEM_RESIZE, rows);
1224
+ rowStore.$update(ACTION_ITEM_RESIZE, rows);
1231
1225
  },
1232
1226
  $dispose: resizeObserver._dispose,
1233
1227
  };