@legendapp/list 3.0.0-beta.35 → 3.0.0-beta.36

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@legendapp/list",
3
- "version": "3.0.0-beta.35",
3
+ "version": "3.0.0-beta.36",
4
4
  "description": "Legend List is a drop-in replacement for FlatList with much better performance and supporting dynamically sized items.",
5
5
  "sideEffects": false,
6
6
  "private": false,
package/reanimated.js CHANGED
@@ -172,18 +172,37 @@ var ReanimatedPositionViewSticky = typedMemo(function ReanimatedPositionViewStic
172
172
  return /* @__PURE__ */ React3__namespace.createElement(Reanimated__default.default.View, { ref: refView, style: viewStyle, ...rest }, /* @__PURE__ */ React3__namespace.createElement(StickyOverlay, { stickyHeaderConfig }), children);
173
173
  });
174
174
  var ReanimatedPositionView = typedMemo(function ReanimatedPositionViewComponent(props) {
175
- const { id, horizontal, style, refView, children, layoutTransition, ...rest } = props;
176
- const [positionValue = POSITION_OUT_OF_VIEW] = useArr$([`containerPosition${id}`]);
175
+ const { id, horizontal, style, refView, children, recycleItems, layoutTransition, ...rest } = props;
176
+ const [positionValue = POSITION_OUT_OF_VIEW, itemKey] = useArr$([
177
+ `containerPosition${id}`,
178
+ `containerItemKey${id}`
179
+ ]);
180
+ const prevItemKeyRef = React3__namespace.useRef(void 0);
181
+ const shouldSkipTransitionForRecycleReuse = !!recycleItems && itemKey !== void 0 && prevItemKeyRef.current !== void 0 && prevItemKeyRef.current !== itemKey;
182
+ React3__namespace.useEffect(() => {
183
+ if (itemKey !== void 0) {
184
+ prevItemKeyRef.current = itemKey;
185
+ }
186
+ }, [itemKey]);
177
187
  const viewStyle = React3__namespace.useMemo(
178
188
  () => [style, horizontal ? { left: positionValue } : { top: positionValue }],
179
189
  [horizontal, positionValue, style]
180
190
  );
181
- return /* @__PURE__ */ React3__namespace.createElement(Reanimated__default.default.View, { layout: layoutTransition, ref: refView, style: viewStyle, ...rest }, children);
191
+ return /* @__PURE__ */ React3__namespace.createElement(
192
+ Reanimated__default.default.View,
193
+ {
194
+ layout: shouldSkipTransitionForRecycleReuse ? void 0 : layoutTransition,
195
+ ref: refView,
196
+ style: viewStyle,
197
+ ...rest
198
+ },
199
+ children
200
+ );
182
201
  });
183
202
  var LegendListForwardedRef = typedMemo(
184
203
  // biome-ignore lint/nursery/noShadow: const function name shadowing is intentional
185
204
  React3__namespace.forwardRef(function LegendListForwardedRef2(props, ref) {
186
- const { itemLayoutAnimation, refLegendList, ...rest } = props;
205
+ const { itemLayoutAnimation, recycleItems, refLegendList, ...rest } = props;
187
206
  const refFn = React3.useCallback(
188
207
  (r) => {
189
208
  refLegendList(r);
@@ -220,9 +239,16 @@ var LegendListForwardedRef = typedMemo(
220
239
  return void 0;
221
240
  }
222
241
  return function PositionComponent(positionProps) {
223
- return /* @__PURE__ */ React3__namespace.createElement(ReanimatedPositionView, { ...positionProps, layoutTransition: itemLayoutAnimationRef.current });
242
+ return /* @__PURE__ */ React3__namespace.createElement(
243
+ ReanimatedPositionView,
244
+ {
245
+ ...positionProps,
246
+ layoutTransition: itemLayoutAnimationRef.current,
247
+ recycleItems
248
+ }
249
+ );
224
250
  };
225
- }, [hasItemLayoutAnimation]);
251
+ }, [hasItemLayoutAnimation, recycleItems]);
226
252
  const legendListProps = {
227
253
  ...rest,
228
254
  positionComponentInternal,
package/reanimated.mjs CHANGED
@@ -148,18 +148,37 @@ var ReanimatedPositionViewSticky = typedMemo(function ReanimatedPositionViewStic
148
148
  return /* @__PURE__ */ React3.createElement(Reanimated.View, { ref: refView, style: viewStyle, ...rest }, /* @__PURE__ */ React3.createElement(StickyOverlay, { stickyHeaderConfig }), children);
149
149
  });
150
150
  var ReanimatedPositionView = typedMemo(function ReanimatedPositionViewComponent(props) {
151
- const { id, horizontal, style, refView, children, layoutTransition, ...rest } = props;
152
- const [positionValue = POSITION_OUT_OF_VIEW] = useArr$([`containerPosition${id}`]);
151
+ const { id, horizontal, style, refView, children, recycleItems, layoutTransition, ...rest } = props;
152
+ const [positionValue = POSITION_OUT_OF_VIEW, itemKey] = useArr$([
153
+ `containerPosition${id}`,
154
+ `containerItemKey${id}`
155
+ ]);
156
+ const prevItemKeyRef = React3.useRef(void 0);
157
+ const shouldSkipTransitionForRecycleReuse = !!recycleItems && itemKey !== void 0 && prevItemKeyRef.current !== void 0 && prevItemKeyRef.current !== itemKey;
158
+ React3.useEffect(() => {
159
+ if (itemKey !== void 0) {
160
+ prevItemKeyRef.current = itemKey;
161
+ }
162
+ }, [itemKey]);
153
163
  const viewStyle = React3.useMemo(
154
164
  () => [style, horizontal ? { left: positionValue } : { top: positionValue }],
155
165
  [horizontal, positionValue, style]
156
166
  );
157
- return /* @__PURE__ */ React3.createElement(Reanimated.View, { layout: layoutTransition, ref: refView, style: viewStyle, ...rest }, children);
167
+ return /* @__PURE__ */ React3.createElement(
168
+ Reanimated.View,
169
+ {
170
+ layout: shouldSkipTransitionForRecycleReuse ? void 0 : layoutTransition,
171
+ ref: refView,
172
+ style: viewStyle,
173
+ ...rest
174
+ },
175
+ children
176
+ );
158
177
  });
159
178
  var LegendListForwardedRef = typedMemo(
160
179
  // biome-ignore lint/nursery/noShadow: const function name shadowing is intentional
161
180
  React3.forwardRef(function LegendListForwardedRef2(props, ref) {
162
- const { itemLayoutAnimation, refLegendList, ...rest } = props;
181
+ const { itemLayoutAnimation, recycleItems, refLegendList, ...rest } = props;
163
182
  const refFn = useCallback(
164
183
  (r) => {
165
184
  refLegendList(r);
@@ -196,9 +215,16 @@ var LegendListForwardedRef = typedMemo(
196
215
  return void 0;
197
216
  }
198
217
  return function PositionComponent(positionProps) {
199
- return /* @__PURE__ */ React3.createElement(ReanimatedPositionView, { ...positionProps, layoutTransition: itemLayoutAnimationRef.current });
218
+ return /* @__PURE__ */ React3.createElement(
219
+ ReanimatedPositionView,
220
+ {
221
+ ...positionProps,
222
+ layoutTransition: itemLayoutAnimationRef.current,
223
+ recycleItems
224
+ }
225
+ );
200
226
  };
201
- }, [hasItemLayoutAnimation]);
227
+ }, [hasItemLayoutAnimation, recycleItems]);
202
228
  const legendListProps = {
203
229
  ...rest,
204
230
  positionComponentInternal,