virtua 0.45.0 → 0.45.2

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.
@@ -246,7 +246,14 @@ const isRTLDocument = /*#__PURE__*/ once(() => {
246
246
  * @internal
247
247
  */
248
248
  const isIOSWebKit = /*#__PURE__*/ once(() => {
249
- return /iP(hone|od|ad)/.test(navigator.userAgent);
249
+ if (/iP(hone|od|ad)/.test(navigator.userAgent)) {
250
+ return true;
251
+ }
252
+ // Modern iPad detection (iPadOS 13+)
253
+ // iPadOS 13+ reports the same userAgent/platform information as macOS, to enable desktop sites.
254
+ // So we treat devices that have macOS like information but with touch support as iPadOS.
255
+ // https://stackoverflow.com/questions/57776001/how-to-detect-ipad-pro-as-ipad-using-javascript
256
+ return navigator.platform === "MacIntel" && navigator.maxTouchPoints > 0;
250
257
  });
251
258
  /**
252
259
  * @internal
@@ -968,9 +975,9 @@ const createWindowScroller = (store, isHorizontal) => {
968
975
  /**
969
976
  * @internal
970
977
  */
971
- const createGridScroller = (vStore, hStore) => {
972
- const vScroller = createScroller(vStore, false);
973
- const hScroller = createScroller(hStore, true);
978
+ const createGridScroller = (rowStore, colStore) => {
979
+ const vScroller = createScroller(rowStore, false);
980
+ const hScroller = createScroller(colStore, true);
974
981
  return {
975
982
  $observe(viewportElement) {
976
983
  vScroller.$observe(viewportElement);
@@ -1111,10 +1118,8 @@ const createWindowResizer = (store, isHorizontal) => {
1111
1118
  /**
1112
1119
  * @internal
1113
1120
  */
1114
- const createGridResizer = (vStore, hStore) => {
1121
+ const createGridResizer = (rowStore, colStore) => {
1115
1122
  let viewportElement;
1116
- const heightKey = "height";
1117
- const widthKey = "width";
1118
1123
  const mountedIndexes = new WeakMap();
1119
1124
  const maybeCachedRowIndexes = new Set();
1120
1125
  const maybeCachedColIndexes = new Set();
@@ -1123,13 +1128,13 @@ const createGridResizer = (vStore, hStore) => {
1123
1128
  const resizeObserver = createResizeObserver((entries) => {
1124
1129
  const resizedRows = new Set();
1125
1130
  const resizedCols = new Set();
1126
- for (const { target, contentRect } of entries) {
1131
+ for (const { target, contentRect: { width, height }, } of entries) {
1127
1132
  // Skip zero-sized rects that may be observed under `display: none` style
1128
1133
  if (!target.offsetParent)
1129
1134
  continue;
1130
1135
  if (target === viewportElement) {
1131
- vStore.$update(ACTION_VIEWPORT_RESIZE, contentRect[heightKey]);
1132
- hStore.$update(ACTION_VIEWPORT_RESIZE, contentRect[widthKey]);
1136
+ rowStore.$update(ACTION_VIEWPORT_RESIZE, height);
1137
+ colStore.$update(ACTION_VIEWPORT_RESIZE, width);
1133
1138
  }
1134
1139
  else {
1135
1140
  const cell = mountedIndexes.get(target);
@@ -1137,20 +1142,16 @@ const createGridResizer = (vStore, hStore) => {
1137
1142
  const [rowIndex, colIndex] = cell;
1138
1143
  const key = getKey(rowIndex, colIndex);
1139
1144
  const prevSize = sizeCache.get(key);
1140
- const size = [
1141
- contentRect[heightKey],
1142
- contentRect[widthKey],
1143
- ];
1144
1145
  let rowResized;
1145
1146
  let colResized;
1146
1147
  if (!prevSize) {
1147
1148
  rowResized = colResized = true;
1148
1149
  }
1149
1150
  else {
1150
- if (prevSize[0] !== size[0]) {
1151
+ if (prevSize[0] !== height) {
1151
1152
  rowResized = true;
1152
1153
  }
1153
- if (prevSize[1] !== size[1]) {
1154
+ if (prevSize[1] !== width) {
1154
1155
  colResized = true;
1155
1156
  }
1156
1157
  }
@@ -1161,7 +1162,7 @@ const createGridResizer = (vStore, hStore) => {
1161
1162
  resizedCols.add(colIndex);
1162
1163
  }
1163
1164
  if (rowResized || colResized) {
1164
- sizeCache.set(key, size);
1165
+ sizeCache.set(key, [height, width]);
1165
1166
  }
1166
1167
  }
1167
1168
  }
@@ -1180,7 +1181,7 @@ const createGridResizer = (vStore, hStore) => {
1180
1181
  heightResizes.push([rowIndex, maxHeight]);
1181
1182
  }
1182
1183
  });
1183
- vStore.$update(ACTION_ITEM_RESIZE, heightResizes);
1184
+ rowStore.$update(ACTION_ITEM_RESIZE, heightResizes);
1184
1185
  }
1185
1186
  if (resizedCols.size) {
1186
1187
  const widthResizes = [];
@@ -1196,7 +1197,7 @@ const createGridResizer = (vStore, hStore) => {
1196
1197
  widthResizes.push([colIndex, maxWidth]);
1197
1198
  }
1198
1199
  });
1199
- hStore.$update(ACTION_ITEM_RESIZE, widthResizes);
1200
+ colStore.$update(ACTION_ITEM_RESIZE, widthResizes);
1200
1201
  }
1201
1202
  });
1202
1203
  return {
@@ -1215,19 +1216,19 @@ const createGridResizer = (vStore, hStore) => {
1215
1216
  },
1216
1217
  $resizeCols(cols) {
1217
1218
  for (const [c] of cols) {
1218
- for (let r = 0; r < vStore.$getItemsLength(); r++) {
1219
+ for (let r = 0; r < rowStore.$getItemsLength(); r++) {
1219
1220
  sizeCache.delete(getKey(r, c));
1220
1221
  }
1221
1222
  }
1222
- hStore.$update(ACTION_ITEM_RESIZE, cols);
1223
+ colStore.$update(ACTION_ITEM_RESIZE, cols);
1223
1224
  },
1224
1225
  $resizeRows(rows) {
1225
1226
  for (const [r] of rows) {
1226
- for (let c = 0; c < hStore.$getItemsLength(); c++) {
1227
+ for (let c = 0; c < colStore.$getItemsLength(); c++) {
1227
1228
  sizeCache.delete(getKey(r, c));
1228
1229
  }
1229
1230
  }
1230
- vStore.$update(ACTION_ITEM_RESIZE, rows);
1231
+ rowStore.$update(ACTION_ITEM_RESIZE, rows);
1231
1232
  },
1232
1233
  $dispose: resizeObserver._dispose,
1233
1234
  };