|
64 | 64 | offset: scrollOffset || (scrollToIndex !== undefined && getOffsetForIndex(scrollToIndex)) || 0,
|
65 | 65 | changeReason: SCROLL_CHANGE_REASON.REQUESTED
|
66 | 66 | });
|
67 |
| - let prevScroll = $state.raw(scroll); |
| 67 | + let prevScroll = $state.snapshot(scroll); |
68 | 68 |
|
69 | 69 | let heightNumber = $derived(Number.isFinite(height) ? Number(height) : wrapperHeight);
|
70 | 70 | let widthNumber = $derived(Number.isFinite(width) ? Number(width) : wrapperWidth);
|
71 |
| - let prevProps = $state.raw({ |
72 |
| - scrollToIndex, |
73 |
| - scrollToAlignment, |
74 |
| - scrollOffset, |
75 |
| - itemCount, |
76 |
| - itemSize, |
77 |
| - estimatedItemSize, |
78 |
| - heightNumber, |
79 |
| - widthNumber, |
80 |
| - stickyIndices |
81 |
| - }); |
| 71 | + let prevProps = { |
| 72 | + scrollToIndex: $state.snapshot(scrollToIndex), |
| 73 | + scrollToAlignment: $state.snapshot(scrollToAlignment), |
| 74 | + scrollOffset: $state.snapshot(scrollOffset), |
| 75 | + itemCount: $state.snapshot(itemCount), |
| 76 | + itemSize: typeof itemSize === 'function' ? itemSize : $state.snapshot(itemSize), |
| 77 | + estimatedItemSize: $state.snapshot(estimatedItemSize), |
| 78 | + heightNumber: $state.snapshot(heightNumber), |
| 79 | + widthNumber: $state.snapshot(widthNumber), |
| 80 | + stickyIndices: $state.snapshot(stickyIndices) |
| 81 | + }; |
82 | 82 |
|
83 | 83 | /** @type {Record<number, string>} */
|
84 | 84 | let styleCache = $state({});
|
|
176 | 176 | scrollToAlignment: $state.snapshot(scrollToAlignment),
|
177 | 177 | scrollOffset: $state.snapshot(scrollOffset),
|
178 | 178 | itemCount: $state.snapshot(itemCount),
|
179 |
| - // @ts-expect-error since snapshot does not support functions properly |
180 |
| - itemSize: $state.snapshot(itemSize), |
| 179 | + itemSize: typeof itemSize === 'function' ? itemSize : $state.snapshot(itemSize), |
181 | 180 | estimatedItemSize: $state.snapshot(estimatedItemSize),
|
182 | 181 | heightNumber: $state.snapshot(heightNumber),
|
183 | 182 | widthNumber: $state.snapshot(widthNumber),
|
|
200 | 199 | });
|
201 | 200 | }
|
202 | 201 |
|
203 |
| - prevScroll = scroll; |
| 202 | + prevScroll = $state.snapshot(scroll); |
204 | 203 | }
|
205 | 204 |
|
206 | 205 | /**
|
|
0 commit comments