virtua 0.53.4 → 0.53.5

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.
@@ -26,8 +26,10 @@
26
26
 
27
27
  <div role="row" aria-rowindex={state.$row + 1} {style}>
28
28
  {#each state.$cells as cell (cell.$col)}
29
- <!-- Guard for experimental.async: true, which runs the each block before $effect.pre -->
29
+ <!-- The each block runs before $effect.pre with experimental.async, so the store may still have the length before the update -->
30
+ <!-- https://svelte.dev/docs/svelte/await-expressions#Breaking-changes -->
30
31
  <!-- https://github.com/inokawa/virtua/pull/847 -->
32
+ <!-- https://github.com/inokawa/virtua/pull/1018 -->
31
33
  {#if cell.$col < getAxisLength(cols)}
32
34
  <GridCell
33
35
  state={cell}
@@ -27,8 +27,10 @@
27
27
  <!-- https://www.w3.org/TR/wai-aria-1.2/#rowgroup -->
28
28
  <div role="rowgroup" {style}>
29
29
  {#each state.$rows as row (row.$row)}
30
- <!-- Guard for experimental.async: true, which runs the each block before $effect.pre -->
30
+ <!-- The each block runs before $effect.pre with experimental.async, so the store may still have the length before the update -->
31
+ <!-- https://svelte.dev/docs/svelte/await-expressions#Breaking-changes -->
31
32
  <!-- https://github.com/inokawa/virtua/pull/847 -->
33
+ <!-- https://github.com/inokawa/virtua/pull/1018 -->
32
34
  {#if row.$row < getAxisLength(rows)}
33
35
  <GridRow
34
36
  state={row}
@@ -242,8 +242,10 @@
242
242
  resizer={driver.$observeItem}
243
243
  />
244
244
  {:else}
245
- <!-- Guard for experimental.async: true, which runs the each block before $effect.pre -->
245
+ <!-- The each block runs before $effect.pre with experimental.async, so the store may still have the length before the update -->
246
+ <!-- https://svelte.dev/docs/svelte/await-expressions#Breaking-changes -->
246
247
  <!-- https://github.com/inokawa/virtua/pull/847 -->
248
+ <!-- https://github.com/inokawa/virtua/pull/1018 -->
247
249
  {#if state.$row < getAxisLength(rows)}
248
250
  <GridRow
249
251
  {state}
@@ -16,6 +16,7 @@
16
16
  scrollTo as _scrollTo,
17
17
  scrollBy as _scrollBy,
18
18
  scrollToIndex as _scrollToIndex,
19
+ min,
19
20
  sort,
20
21
  } from "../core/index.js";
21
22
  import { defaultGetKey, isSameRange, styleToString } from "./utils.js";
@@ -86,7 +87,11 @@
86
87
  let crossSize = $derived(toCrossValue(1 / lanes, gap / lanes - gap));
87
88
 
88
89
  let indexes = $derived.by(() => {
89
- const len = data.length;
90
+ // The each block runs before $effect.pre with experimental.async, so the store may still have the length before the update
91
+ // https://svelte.dev/docs/svelte/await-expressions#Breaking-changes
92
+ // https://github.com/inokawa/virtua/pull/847
93
+ // https://github.com/inokawa/virtua/pull/1018
94
+ const len = stateVersion && min(data.length, layout.$getLength());
90
95
  const [start, end] = range;
91
96
  const arr: number[] = [];
92
97
  if (keepMounted) {
@@ -94,17 +99,13 @@
94
99
  for (let i = start; i <= end; i++) {
95
100
  mounted.add(i);
96
101
  }
97
- // The store may still have the previous length in async mode, as the range does
98
- const storeLen = stateVersion && layout.$getLength();
99
102
  for (const index of sort([...mounted])) {
100
- if (index < len && index < storeLen) {
103
+ if (index < len) {
101
104
  arr.push(index);
102
105
  }
103
106
  }
104
107
  } else {
105
108
  for (let i = start; i <= end; i++) {
106
- // Guard for experimental.async: true, which runs the each block before $effect.pre
107
- // https://github.com/inokawa/virtua/pull/847
108
109
  if (i < len) {
109
110
  arr.push(i);
110
111
  }
@@ -16,6 +16,7 @@
16
16
  createVirtualStore,
17
17
  createListLayout,
18
18
  getScrollSize as _getScrollSize,
19
+ min,
19
20
  sort,
20
21
  } from "../core/index.js";
21
22
  import { defaultGetKey, isSameRange, styleToString } from "./utils.js";
@@ -83,7 +84,11 @@
83
84
  let totalSize = $derived(stateVersion && store.$getTotalSize());
84
85
 
85
86
  let indexes = $derived.by(() => {
86
- const len = data.length;
87
+ // The each block runs before $effect.pre with experimental.async, so the store may still have the length before the update
88
+ // https://svelte.dev/docs/svelte/await-expressions#Breaking-changes
89
+ // https://github.com/inokawa/virtua/pull/847
90
+ // https://github.com/inokawa/virtua/pull/1018
91
+ const len = stateVersion && min(data.length, layout.$getLength());
87
92
 
88
93
  const [start, end] = range;
89
94
  const arr: number[] = [];
@@ -92,17 +97,13 @@
92
97
  for (let i = start; i <= end; i++) {
93
98
  mounted.add(i);
94
99
  }
95
- // The store may still have the previous length in async mode, as the range does
96
- const storeLen = stateVersion && layout.$getLength();
97
100
  for (const index of sort([...mounted])) {
98
- if (index < len && index < storeLen) {
101
+ if (index < len) {
99
102
  arr.push(index);
100
103
  }
101
104
  }
102
105
  } else {
103
106
  for (let i = start; i <= end; i++) {
104
- // Guard for experimental.async: true, which runs the each block before $effect.pre
105
- // https://github.com/inokawa/virtua/pull/847
106
107
  if (i < len) {
107
108
  arr.push(i);
108
109
  }
@@ -136,9 +137,7 @@
136
137
  });
137
138
 
138
139
  $effect.pre(() => {
139
- if (startMargin !== store.$getStartSpacerSize()) {
140
- store.$update(ACTION_START_OFFSET_CHANGE, startMargin);
141
- }
140
+ store.$update(ACTION_START_OFFSET_CHANGE, startMargin);
142
141
  });
143
142
 
144
143
  let prevStateVersion: StateVersion | undefined;
@@ -13,6 +13,7 @@
13
13
  getScrollSize as _getScrollSize,
14
14
  createWindowDriver,
15
15
  scrollToIndex as _scrollToIndex,
16
+ min,
16
17
  } from "../core/index.js";
17
18
  import { defaultGetKey, isSameRange, styleToString } from "./utils.js";
18
19
  import ListItem from "./ListItem.svelte";
@@ -74,13 +75,15 @@
74
75
  let totalSize = $derived(stateVersion && store.$getTotalSize());
75
76
 
76
77
  let indexes = $derived.by(() => {
77
- const len = data.length;
78
+ // The each block runs before $effect.pre with experimental.async, so the store may still have the length before the update
79
+ // https://svelte.dev/docs/svelte/await-expressions#Breaking-changes
80
+ // https://github.com/inokawa/virtua/pull/847
81
+ // https://github.com/inokawa/virtua/pull/1018
82
+ const len = stateVersion && min(data.length, layout.$getLength());
78
83
 
79
84
  const [start, end] = range;
80
85
  const arr: number[] = [];
81
86
  for (let i = start; i <= end; i++) {
82
- // Guard for experimental.async: true, which runs the each block before $effect.pre
83
- // https://github.com/inokawa/virtua/pull/847
84
87
  if (i < len) {
85
88
  arr.push(i);
86
89
  }
package/lib/vue/index.cjs CHANGED
@@ -347,11 +347,13 @@ t), g = e => n(e.t(), e.o()), $ = (e, t, o, r) => {
347
347
  passive: !0
348
348
  }), o.addEventListener("touchend", R, {
349
349
  passive: !0
350
+ }), o.addEventListener("touchcancel", R, {
351
+ passive: !0
350
352
  }), {
351
353
  J: k,
352
354
  X: () => {
353
355
  o.removeEventListener("scroll", k), o.removeEventListener("wheel", O), o.removeEventListener("touchstart", T),
354
- o.removeEventListener("touchend", R), a(d);
356
+ o.removeEventListener("touchend", R), o.removeEventListener("touchcancel", R), a(d);
355
357
  },
356
358
  D: () => {
357
359
  const [t, o] = e.C();