@legendapp/list 2.1.0-beta.2 → 2.1.0-beta.3

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/index.d.mts CHANGED
@@ -37,7 +37,7 @@ declare class ScrollAdjustHandler {
37
37
  getAdjust(): number;
38
38
  }
39
39
 
40
- type BaseScrollViewProps<TScrollView> = Omit<TScrollView, "contentOffset" | "contentInset" | "maintainVisibleContentPosition" | "stickyHeaderIndices" | "removeClippedSubviews" | "children" | "onScroll">;
40
+ type BaseScrollViewProps<TScrollView> = Omit<TScrollView, "contentOffset" | "maintainVisibleContentPosition" | "stickyHeaderIndices" | "removeClippedSubviews" | "children" | "onScroll">;
41
41
  interface DataModeProps<ItemT, TItemType extends string | undefined> {
42
42
  /**
43
43
  * Array of items to render in the list.
@@ -403,7 +403,6 @@ interface InternalState {
403
403
  suggestEstimatedItemSize: boolean;
404
404
  stylePaddingBottom: number | undefined;
405
405
  renderItem: LegendListProps["renderItem"];
406
- initialScroll: ScrollIndexWithOffset | undefined;
407
406
  scrollBuffer: number;
408
407
  numColumns: number;
409
408
  initialContainerPoolRatio: number;
package/index.d.ts CHANGED
@@ -37,7 +37,7 @@ declare class ScrollAdjustHandler {
37
37
  getAdjust(): number;
38
38
  }
39
39
 
40
- type BaseScrollViewProps<TScrollView> = Omit<TScrollView, "contentOffset" | "contentInset" | "maintainVisibleContentPosition" | "stickyHeaderIndices" | "removeClippedSubviews" | "children" | "onScroll">;
40
+ type BaseScrollViewProps<TScrollView> = Omit<TScrollView, "contentOffset" | "maintainVisibleContentPosition" | "stickyHeaderIndices" | "removeClippedSubviews" | "children" | "onScroll">;
41
41
  interface DataModeProps<ItemT, TItemType extends string | undefined> {
42
42
  /**
43
43
  * Array of items to render in the list.
@@ -403,7 +403,6 @@ interface InternalState {
403
403
  suggestEstimatedItemSize: boolean;
404
404
  stylePaddingBottom: number | undefined;
405
405
  renderItem: LegendListProps["renderItem"];
406
- initialScroll: ScrollIndexWithOffset | undefined;
407
406
  scrollBuffer: number;
408
407
  numColumns: number;
409
408
  initialContainerPoolRatio: number;
package/index.js CHANGED
@@ -1415,8 +1415,9 @@ function updateScroll(ctx, state, newScroll, forceUpdate) {
1415
1415
  // src/core/finishScrollTo.ts
1416
1416
  function finishScrollTo(ctx, state) {
1417
1417
  if (state) {
1418
- set$(ctx, "scrollingTo", void 0);
1419
1418
  state.scrollHistory.length = 0;
1419
+ state.initialScroll = void 0;
1420
+ set$(ctx, "scrollingTo", void 0);
1420
1421
  }
1421
1422
  }
1422
1423
 
@@ -2797,13 +2798,15 @@ var ScrollAdjustHandler = class {
2797
2798
  const commitPendingAdjust = () => {
2798
2799
  const state = this.context.internalState;
2799
2800
  const pending = this.pendingAdjust;
2800
- this.pendingAdjust = 0;
2801
- this.appliedAdjust += pending;
2802
- state.scroll += pending;
2803
- state.scrollForNextCalculateItemsInView = void 0;
2804
- set$(this.context, "scrollAdjustPending", 0);
2805
- set$(this.context, "scrollAdjust", this.appliedAdjust);
2806
- calculateItemsInView(this.context, this.context.internalState);
2801
+ if (pending !== 0) {
2802
+ this.pendingAdjust = 0;
2803
+ this.appliedAdjust += pending;
2804
+ state.scroll += pending;
2805
+ state.scrollForNextCalculateItemsInView = void 0;
2806
+ set$(this.context, "scrollAdjustPending", 0);
2807
+ set$(this.context, "scrollAdjust", this.appliedAdjust);
2808
+ calculateItemsInView(this.context, this.context.internalState);
2809
+ }
2807
2810
  };
2808
2811
  listen$(this.context, "scrollingTo", (value) => {
2809
2812
  if (value === void 0) {
@@ -3153,7 +3156,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3153
3156
  ...rest
3154
3157
  } = props;
3155
3158
  const [renderNum, setRenderNum] = React3.useState(0);
3156
- const initialScroll = initialScrollIndexProp || initialScrollOffsetProp ? typeof initialScrollIndexProp === "object" ? { index: initialScrollIndexProp.index || 0, viewOffset: initialScrollIndexProp.viewOffset || 0 } : { index: initialScrollIndexProp || 0, viewOffset: initialScrollOffsetProp || 0 } : void 0;
3159
+ const initialScrollProp = initialScrollIndexProp || initialScrollOffsetProp ? typeof initialScrollIndexProp === "object" ? { index: initialScrollIndexProp.index || 0, viewOffset: initialScrollIndexProp.viewOffset || 0 } : { index: initialScrollIndexProp || 0, viewOffset: initialScrollOffsetProp || 0 } : void 0;
3157
3160
  const [canRender, setCanRender] = React3__namespace.useState(!IsNewArchitecture);
3158
3161
  const contentContainerStyle = { ...StyleSheet.flatten(contentContainerStyleProp) };
3159
3162
  const style = { ...StyleSheet.flatten(styleProp) };
@@ -3185,7 +3188,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3185
3188
  idCache: [],
3186
3189
  idsInView: [],
3187
3190
  indexByKey: /* @__PURE__ */ new Map(),
3188
- initialScroll,
3191
+ initialScroll: initialScrollProp,
3189
3192
  isAtEnd: false,
3190
3193
  isAtStart: false,
3191
3194
  isEndReached: false,
@@ -3243,7 +3246,6 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3243
3246
  getItemType,
3244
3247
  horizontal: !!horizontal,
3245
3248
  initialContainerPoolRatio,
3246
- initialScroll,
3247
3249
  itemsAreEqual,
3248
3250
  keyExtractor,
3249
3251
  maintainScrollAtEnd,
@@ -3300,6 +3302,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3300
3302
  );
3301
3303
  }
3302
3304
  const initialContentOffset = React3.useMemo(() => {
3305
+ const { initialScroll } = refState.current;
3303
3306
  if (initialScroll) {
3304
3307
  const { index, viewOffset } = initialScroll;
3305
3308
  let initialContentOffset2 = viewOffset || 0;
@@ -3332,6 +3335,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3332
3335
  }
3333
3336
  }
3334
3337
  const onLayoutHeader = React3.useCallback((rect, fromLayoutEffect) => {
3338
+ const { initialScroll } = refState.current;
3335
3339
  const size = rect[horizontal ? "width" : "height"];
3336
3340
  set$(ctx, "headerSize", size);
3337
3341
  if ((initialScroll == null ? void 0 : initialScroll.index) !== void 0) {
@@ -3470,6 +3474,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3470
3474
  }, []);
3471
3475
  {
3472
3476
  React3.useEffect(() => {
3477
+ const { initialScroll } = refState.current;
3473
3478
  if (initialContentOffset) {
3474
3479
  scrollTo(ctx, state, { animated: false, offset: initialContentOffset, ...initialScroll || {} });
3475
3480
  }
package/index.mjs CHANGED
@@ -1394,8 +1394,9 @@ function updateScroll(ctx, state, newScroll, forceUpdate) {
1394
1394
  // src/core/finishScrollTo.ts
1395
1395
  function finishScrollTo(ctx, state) {
1396
1396
  if (state) {
1397
- set$(ctx, "scrollingTo", void 0);
1398
1397
  state.scrollHistory.length = 0;
1398
+ state.initialScroll = void 0;
1399
+ set$(ctx, "scrollingTo", void 0);
1399
1400
  }
1400
1401
  }
1401
1402
 
@@ -2776,13 +2777,15 @@ var ScrollAdjustHandler = class {
2776
2777
  const commitPendingAdjust = () => {
2777
2778
  const state = this.context.internalState;
2778
2779
  const pending = this.pendingAdjust;
2779
- this.pendingAdjust = 0;
2780
- this.appliedAdjust += pending;
2781
- state.scroll += pending;
2782
- state.scrollForNextCalculateItemsInView = void 0;
2783
- set$(this.context, "scrollAdjustPending", 0);
2784
- set$(this.context, "scrollAdjust", this.appliedAdjust);
2785
- calculateItemsInView(this.context, this.context.internalState);
2780
+ if (pending !== 0) {
2781
+ this.pendingAdjust = 0;
2782
+ this.appliedAdjust += pending;
2783
+ state.scroll += pending;
2784
+ state.scrollForNextCalculateItemsInView = void 0;
2785
+ set$(this.context, "scrollAdjustPending", 0);
2786
+ set$(this.context, "scrollAdjust", this.appliedAdjust);
2787
+ calculateItemsInView(this.context, this.context.internalState);
2788
+ }
2786
2789
  };
2787
2790
  listen$(this.context, "scrollingTo", (value) => {
2788
2791
  if (value === void 0) {
@@ -3132,7 +3135,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3132
3135
  ...rest
3133
3136
  } = props;
3134
3137
  const [renderNum, setRenderNum] = useState(0);
3135
- const initialScroll = initialScrollIndexProp || initialScrollOffsetProp ? typeof initialScrollIndexProp === "object" ? { index: initialScrollIndexProp.index || 0, viewOffset: initialScrollIndexProp.viewOffset || 0 } : { index: initialScrollIndexProp || 0, viewOffset: initialScrollOffsetProp || 0 } : void 0;
3138
+ const initialScrollProp = initialScrollIndexProp || initialScrollOffsetProp ? typeof initialScrollIndexProp === "object" ? { index: initialScrollIndexProp.index || 0, viewOffset: initialScrollIndexProp.viewOffset || 0 } : { index: initialScrollIndexProp || 0, viewOffset: initialScrollOffsetProp || 0 } : void 0;
3136
3139
  const [canRender, setCanRender] = React3.useState(!IsNewArchitecture);
3137
3140
  const contentContainerStyle = { ...StyleSheet.flatten(contentContainerStyleProp) };
3138
3141
  const style = { ...StyleSheet.flatten(styleProp) };
@@ -3164,7 +3167,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3164
3167
  idCache: [],
3165
3168
  idsInView: [],
3166
3169
  indexByKey: /* @__PURE__ */ new Map(),
3167
- initialScroll,
3170
+ initialScroll: initialScrollProp,
3168
3171
  isAtEnd: false,
3169
3172
  isAtStart: false,
3170
3173
  isEndReached: false,
@@ -3222,7 +3225,6 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3222
3225
  getItemType,
3223
3226
  horizontal: !!horizontal,
3224
3227
  initialContainerPoolRatio,
3225
- initialScroll,
3226
3228
  itemsAreEqual,
3227
3229
  keyExtractor,
3228
3230
  maintainScrollAtEnd,
@@ -3279,6 +3281,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3279
3281
  );
3280
3282
  }
3281
3283
  const initialContentOffset = useMemo(() => {
3284
+ const { initialScroll } = refState.current;
3282
3285
  if (initialScroll) {
3283
3286
  const { index, viewOffset } = initialScroll;
3284
3287
  let initialContentOffset2 = viewOffset || 0;
@@ -3311,6 +3314,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3311
3314
  }
3312
3315
  }
3313
3316
  const onLayoutHeader = useCallback((rect, fromLayoutEffect) => {
3317
+ const { initialScroll } = refState.current;
3314
3318
  const size = rect[horizontal ? "width" : "height"];
3315
3319
  set$(ctx, "headerSize", size);
3316
3320
  if ((initialScroll == null ? void 0 : initialScroll.index) !== void 0) {
@@ -3449,6 +3453,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3449
3453
  }, []);
3450
3454
  {
3451
3455
  useEffect(() => {
3456
+ const { initialScroll } = refState.current;
3452
3457
  if (initialContentOffset) {
3453
3458
  scrollTo(ctx, state, { animated: false, offset: initialContentOffset, ...initialScroll || {} });
3454
3459
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@legendapp/list",
3
- "version": "2.1.0-beta.2",
3
+ "version": "2.1.0-beta.3",
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,