@legendapp/list 0.6.2 → 0.6.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
@@ -101,6 +101,11 @@ interface InternalState {
101
101
  }>;
102
102
  scrollTimer: Timer | undefined;
103
103
  startReachedBlockedByTimer: boolean;
104
+ layoutsPending: Set<number>;
105
+ scrollForNextCalculateItemsInView: {
106
+ top: number;
107
+ bottom: number;
108
+ } | undefined;
104
109
  }
105
110
  interface ViewableRange<T> {
106
111
  startBuffered: number;
package/index.d.ts CHANGED
@@ -101,6 +101,11 @@ interface InternalState {
101
101
  }>;
102
102
  scrollTimer: Timer | undefined;
103
103
  startReachedBlockedByTimer: boolean;
104
+ layoutsPending: Set<number>;
105
+ scrollForNextCalculateItemsInView: {
106
+ top: number;
107
+ bottom: number;
108
+ } | undefined;
104
109
  }
105
110
  interface ViewableRange<T> {
106
111
  startBuffered: number;
package/index.js CHANGED
@@ -39,12 +39,16 @@ function StateProvider({ children }) {
39
39
  function useStateContext() {
40
40
  return React4__namespace.useContext(ContextState);
41
41
  }
42
+ function createSelectorFunctions(ctx, signalName) {
43
+ return {
44
+ subscribe: (cb) => listen$(ctx, signalName, cb),
45
+ get: () => peek$(ctx, signalName)
46
+ };
47
+ }
42
48
  function use$(signalName) {
43
49
  const ctx = React4__namespace.useContext(ContextState);
44
- const value = React4.useSyncExternalStore(
45
- (onStoreChange) => listen$(ctx, signalName, onStoreChange),
46
- () => ctx.values.get(signalName)
47
- );
50
+ const { subscribe, get } = React4__namespace.useMemo(() => createSelectorFunctions(ctx, signalName), []);
51
+ const value = React4.useSyncExternalStore(subscribe, get);
48
52
  return value;
49
53
  }
50
54
  function listen$(ctx, signalName, cb) {
@@ -118,14 +122,6 @@ var Container = ({
118
122
  if (key !== void 0) {
119
123
  const size = Math.floor(event.nativeEvent.layout[horizontal ? "width" : "height"] * 8) / 8;
120
124
  updateItemSize(id, key, size);
121
- const otherAxisSize2 = horizontal ? event.nativeEvent.layout.width : event.nativeEvent.layout.height;
122
- set$(ctx, "otherAxisSize", Math.max(otherAxisSize2, peek$(ctx, "otherAxisSize") || 0));
123
- const measured = peek$(ctx, `containerDidLayout${id}`);
124
- if (!measured) {
125
- requestAnimationFrame(() => {
126
- set$(ctx, `containerDidLayout${id}`, true);
127
- });
128
- }
129
125
  }
130
126
  }
131
127
  },
@@ -460,7 +456,7 @@ var LegendList = React4.forwardRef(function LegendList2(props, forwardedRef) {
460
456
  return /* @__PURE__ */ React4__namespace.createElement(StateProvider, null, /* @__PURE__ */ React4__namespace.createElement(LegendListInner, { ...props, ref: forwardedRef }));
461
457
  });
462
458
  var LegendListInner = React4.forwardRef(function LegendListInner2(props, forwardedRef) {
463
- var _a, _b, _c, _d, _e;
459
+ var _a, _b, _c, _d;
464
460
  const {
465
461
  data,
466
462
  initialScrollIndex,
@@ -567,7 +563,9 @@ var LegendListInner = React4.forwardRef(function LegendListInner2(props, forward
567
563
  scrollTimer: void 0,
568
564
  belowAnchorElementPositions: void 0,
569
565
  rowHeights: /* @__PURE__ */ new Map(),
570
- startReachedBlockedByTimer: false
566
+ startReachedBlockedByTimer: false,
567
+ layoutsPending: /* @__PURE__ */ new Set(),
568
+ scrollForNextCalculateItemsInView: void 0
571
569
  };
572
570
  refState.current.idsInFirstRender = new Set(data.map((_, i) => getId(i)));
573
571
  if (maintainVisibleContentPosition) {
@@ -698,7 +696,8 @@ var LegendListInner = React4.forwardRef(function LegendListInner2(props, forward
698
696
  startBufferedId: startBufferedIdOrig,
699
697
  positions,
700
698
  columns,
701
- scrollAdjustHandler
699
+ scrollAdjustHandler,
700
+ layoutsPending
702
701
  } = state;
703
702
  if (state.animFrameLayout) {
704
703
  cancelAnimationFrame(state.animFrameLayout);
@@ -711,6 +710,12 @@ var LegendListInner = React4.forwardRef(function LegendListInner2(props, forward
711
710
  const previousScrollAdjust = scrollAdjustHandler.getAppliedAdjust();
712
711
  const scrollExtra = Math.max(-16, Math.min(16, speed)) * 16;
713
712
  const scroll = scrollState - previousScrollAdjust - topPad - scrollExtra;
713
+ if (refState.current.scrollForNextCalculateItemsInView) {
714
+ const { top: top2, bottom } = refState.current.scrollForNextCalculateItemsInView;
715
+ if (scroll > top2 && scroll < bottom) {
716
+ return;
717
+ }
718
+ }
714
719
  const scrollBottom = scroll + scrollLength;
715
720
  let startNoBuffer = null;
716
721
  let startBuffered = null;
@@ -804,6 +809,14 @@ var LegendListInner = React4.forwardRef(function LegendListInner2(props, forward
804
809
  endBuffered,
805
810
  endNoBuffer
806
811
  });
812
+ const nextTop = Math.ceil(startBuffered ? positions.get(startBufferedId) + scrollBuffer : 0);
813
+ const nextBottom = Math.floor(
814
+ endBuffered ? (positions.get(getId(endBuffered + 1)) || 0) - scrollLength - scrollBuffer : 0
815
+ );
816
+ refState.current.scrollForNextCalculateItemsInView = nextTop >= 0 && nextBottom >= 0 ? {
817
+ top: nextTop,
818
+ bottom: nextBottom
819
+ } : void 0;
807
820
  if (startBuffered !== null && endBuffered !== null) {
808
821
  const prevNumContainers = ctx.values.get("numContainers");
809
822
  let numContainers = prevNumContainers;
@@ -846,7 +859,7 @@ var LegendListInner = React4.forwardRef(function LegendListInner2(props, forward
846
859
  numContainers++;
847
860
  set$(ctx, `containerItemKey${containerId}`, id);
848
861
  const index = (_c2 = refState.current) == null ? void 0 : _c2.indexByKey.get(id);
849
- set$(ctx, `containerItemData${furthestIndex}`, data2[index]);
862
+ set$(ctx, `containerItemData${containerId}`, data2[index]);
850
863
  set$(ctx, `containerPosition${containerId}`, POSITION_OUT_OF_VIEW);
851
864
  set$(ctx, `containerColumn${containerId}`, -1);
852
865
  if (__DEV__ && numContainers > peek$(ctx, "numContainersPooled")) {
@@ -896,6 +909,12 @@ var LegendListInner = React4.forwardRef(function LegendListInner2(props, forward
896
909
  }
897
910
  }
898
911
  }
912
+ if (layoutsPending.size > 0) {
913
+ for (const containerId of layoutsPending) {
914
+ set$(ctx, `containerDidLayout${containerId}`, true);
915
+ }
916
+ layoutsPending.clear();
917
+ }
899
918
  if (refState.current.viewabilityConfigCallbackPairs) {
900
919
  updateViewableItems(
901
920
  refState.current,
@@ -977,6 +996,33 @@ var LegendListInner = React4.forwardRef(function LegendListInner2(props, forward
977
996
  }
978
997
  }
979
998
  };
999
+ const resetContainers = () => {
1000
+ const state = refState.current;
1001
+ if (state) {
1002
+ if (data.length > state.data.length) {
1003
+ state.isEndReached = false;
1004
+ }
1005
+ refState.current.scrollForNextCalculateItemsInView = void 0;
1006
+ state.data = data;
1007
+ const numContainers = peek$(ctx, "numContainers");
1008
+ for (let i = 0; i < numContainers; i++) {
1009
+ const itemKey = peek$(ctx, `containerItemKey${i}`);
1010
+ if (!keyExtractorProp || itemKey && state.indexByKey.get(itemKey) === void 0) {
1011
+ set$(ctx, `containerItemKey${i}`, void 0);
1012
+ set$(ctx, `containerPosition${i}`, POSITION_OUT_OF_VIEW);
1013
+ set$(ctx, `containerColumn${i}`, -1);
1014
+ }
1015
+ }
1016
+ if (!keyExtractorProp) {
1017
+ state.sizes.clear();
1018
+ state.positions;
1019
+ }
1020
+ calculateItemsInView(state.scrollVelocity);
1021
+ doMaintainScrollAtEnd(false);
1022
+ checkAtTop();
1023
+ checkAtBottom();
1024
+ }
1025
+ };
980
1026
  const isFirst = !refState.current.renderItem;
981
1027
  if (isFirst || data !== refState.current.data || numColumnsProp !== peek$(ctx, "numColumns")) {
982
1028
  if (!keyExtractorProp && !isFirst && data !== refState.current.data) {
@@ -1010,40 +1056,24 @@ var LegendListInner = React4.forwardRef(function LegendListInner2(props, forward
1010
1056
  }
1011
1057
  }
1012
1058
  addTotalSize(null, totalSize, totalSizeBelowIndex);
1059
+ }
1060
+ React4.useEffect(() => {
1013
1061
  if (!isFirst) {
1014
- if (data.length > refState.current.data.length) {
1015
- refState.current.isEndReached = false;
1016
- }
1017
- refState.current.data = data;
1018
- const numContainers = peek$(ctx, "numContainers");
1019
- for (let i = 0; i < numContainers; i++) {
1020
- const itemKey = peek$(ctx, `containerItemKey${i}`);
1021
- if (!keyExtractorProp || itemKey && ((_a = refState.current) == null ? void 0 : _a.indexByKey.get(itemKey)) === void 0) {
1022
- set$(ctx, `containerItemKey${i}`, void 0);
1023
- set$(ctx, `containerPosition${i}`, POSITION_OUT_OF_VIEW);
1024
- set$(ctx, `containerColumn${i}`, -1);
1025
- }
1026
- }
1027
- if (!keyExtractorProp) {
1028
- refState.current.sizes.clear();
1029
- refState.current.positions;
1030
- }
1031
- setTimeout(() => {
1032
- calculateItemsInView(refState.current.scrollVelocity);
1033
- doMaintainScrollAtEnd(false);
1034
- checkAtTop();
1035
- checkAtBottom();
1036
- }, 0);
1062
+ resetContainers();
1037
1063
  }
1038
- }
1064
+ }, [isFirst, data, numColumnsProp]);
1039
1065
  refState.current.renderItem = renderItem;
1040
- set$(ctx, "lastItemKey", getId(data[data.length - 1]));
1041
- set$(ctx, "numColumns", numColumnsProp);
1042
- set$(
1043
- ctx,
1044
- "stylePaddingTop",
1045
- (_e = (_d = (_b = reactNative.StyleSheet.flatten(style)) == null ? void 0 : _b.paddingTop) != null ? _d : (_c = reactNative.StyleSheet.flatten(contentContainerStyle)) == null ? void 0 : _c.paddingTop) != null ? _e : 0
1046
- );
1066
+ const lastItemKey = getId(data[data.length - 1]);
1067
+ const stylePaddingTop = (_d = (_c = (_a = reactNative.StyleSheet.flatten(style)) == null ? void 0 : _a.paddingTop) != null ? _c : (_b = reactNative.StyleSheet.flatten(contentContainerStyle)) == null ? void 0 : _b.paddingTop) != null ? _d : 0;
1068
+ const initalizeStateVars = () => {
1069
+ set$(ctx, "lastItemKey", lastItemKey);
1070
+ set$(ctx, "numColumns", numColumnsProp);
1071
+ set$(ctx, "stylePaddingTop", stylePaddingTop);
1072
+ };
1073
+ if (isFirst) {
1074
+ initalizeStateVars();
1075
+ }
1076
+ React4.useEffect(initalizeStateVars, [lastItemKey, numColumnsProp, stylePaddingTop]);
1047
1077
  const getRenderedItem = React4.useCallback((key, containerId) => {
1048
1078
  var _a2, _b2;
1049
1079
  const state = refState.current;
@@ -1111,7 +1141,7 @@ var LegendListInner = React4.forwardRef(function LegendListInner2(props, forward
1111
1141
  }
1112
1142
  };
1113
1143
  run();
1114
- listen$(ctx, signal, run);
1144
+ return listen$(ctx, signal, run);
1115
1145
  }, []);
1116
1146
  };
1117
1147
  const useRecyclingState = (valueOrFun) => {
@@ -1165,6 +1195,10 @@ var LegendListInner = React4.forwardRef(function LegendListInner2(props, forward
1165
1195
  const numColumns = peek$(ctx, "numColumns");
1166
1196
  const row = Math.floor(index / numColumns);
1167
1197
  const prevSize = getRowHeight(row);
1198
+ const measured = peek$(ctx, `containerDidLayout${containerId}`);
1199
+ if (!measured) {
1200
+ state.layoutsPending.add(containerId);
1201
+ }
1168
1202
  if (!prevSize || Math.abs(prevSize - size) > 0.5) {
1169
1203
  let diff;
1170
1204
  if (numColumns > 1) {
@@ -1202,6 +1236,7 @@ var LegendListInner = React4.forwardRef(function LegendListInner2(props, forward
1202
1236
  );
1203
1237
  }, 1e3);
1204
1238
  }
1239
+ refState.current.scrollForNextCalculateItemsInView = void 0;
1205
1240
  addTotalSize(itemKey, diff, 0);
1206
1241
  doMaintainScrollAtEnd(true);
1207
1242
  const scrollVelocity = state.scrollVelocity;
@@ -1215,6 +1250,8 @@ var LegendListInner = React4.forwardRef(function LegendListInner2(props, forward
1215
1250
  calculateItemsInView(state.scrollVelocity);
1216
1251
  }
1217
1252
  }
1253
+ } else {
1254
+ set$(ctx, `containerDidLayout${containerId}`, true);
1218
1255
  }
1219
1256
  }, []);
1220
1257
  const handleScrollDebounced = React4.useCallback((velocity) => {
package/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as React4 from 'react';
2
- import React4__default, { forwardRef, useRef, useMemo, useCallback, useImperativeHandle, useSyncExternalStore, useEffect, useState } from 'react';
2
+ import React4__default, { forwardRef, useRef, useMemo, useCallback, useEffect, useImperativeHandle, useSyncExternalStore, useState } from 'react';
3
3
  import { Animated, ScrollView, View, Dimensions, StyleSheet, useAnimatedValue as useAnimatedValue$1 } from 'react-native';
4
4
 
5
5
  // src/LegendList.tsx
@@ -18,12 +18,16 @@ function StateProvider({ children }) {
18
18
  function useStateContext() {
19
19
  return React4.useContext(ContextState);
20
20
  }
21
+ function createSelectorFunctions(ctx, signalName) {
22
+ return {
23
+ subscribe: (cb) => listen$(ctx, signalName, cb),
24
+ get: () => peek$(ctx, signalName)
25
+ };
26
+ }
21
27
  function use$(signalName) {
22
28
  const ctx = React4.useContext(ContextState);
23
- const value = useSyncExternalStore(
24
- (onStoreChange) => listen$(ctx, signalName, onStoreChange),
25
- () => ctx.values.get(signalName)
26
- );
29
+ const { subscribe, get } = React4.useMemo(() => createSelectorFunctions(ctx, signalName), []);
30
+ const value = useSyncExternalStore(subscribe, get);
27
31
  return value;
28
32
  }
29
33
  function listen$(ctx, signalName, cb) {
@@ -97,14 +101,6 @@ var Container = ({
97
101
  if (key !== void 0) {
98
102
  const size = Math.floor(event.nativeEvent.layout[horizontal ? "width" : "height"] * 8) / 8;
99
103
  updateItemSize(id, key, size);
100
- const otherAxisSize2 = horizontal ? event.nativeEvent.layout.width : event.nativeEvent.layout.height;
101
- set$(ctx, "otherAxisSize", Math.max(otherAxisSize2, peek$(ctx, "otherAxisSize") || 0));
102
- const measured = peek$(ctx, `containerDidLayout${id}`);
103
- if (!measured) {
104
- requestAnimationFrame(() => {
105
- set$(ctx, `containerDidLayout${id}`, true);
106
- });
107
- }
108
104
  }
109
105
  }
110
106
  },
@@ -439,7 +435,7 @@ var LegendList = forwardRef(function LegendList2(props, forwardedRef) {
439
435
  return /* @__PURE__ */ React4.createElement(StateProvider, null, /* @__PURE__ */ React4.createElement(LegendListInner, { ...props, ref: forwardedRef }));
440
436
  });
441
437
  var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef) {
442
- var _a, _b, _c, _d, _e;
438
+ var _a, _b, _c, _d;
443
439
  const {
444
440
  data,
445
441
  initialScrollIndex,
@@ -546,7 +542,9 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
546
542
  scrollTimer: void 0,
547
543
  belowAnchorElementPositions: void 0,
548
544
  rowHeights: /* @__PURE__ */ new Map(),
549
- startReachedBlockedByTimer: false
545
+ startReachedBlockedByTimer: false,
546
+ layoutsPending: /* @__PURE__ */ new Set(),
547
+ scrollForNextCalculateItemsInView: void 0
550
548
  };
551
549
  refState.current.idsInFirstRender = new Set(data.map((_, i) => getId(i)));
552
550
  if (maintainVisibleContentPosition) {
@@ -677,7 +675,8 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
677
675
  startBufferedId: startBufferedIdOrig,
678
676
  positions,
679
677
  columns,
680
- scrollAdjustHandler
678
+ scrollAdjustHandler,
679
+ layoutsPending
681
680
  } = state;
682
681
  if (state.animFrameLayout) {
683
682
  cancelAnimationFrame(state.animFrameLayout);
@@ -690,6 +689,12 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
690
689
  const previousScrollAdjust = scrollAdjustHandler.getAppliedAdjust();
691
690
  const scrollExtra = Math.max(-16, Math.min(16, speed)) * 16;
692
691
  const scroll = scrollState - previousScrollAdjust - topPad - scrollExtra;
692
+ if (refState.current.scrollForNextCalculateItemsInView) {
693
+ const { top: top2, bottom } = refState.current.scrollForNextCalculateItemsInView;
694
+ if (scroll > top2 && scroll < bottom) {
695
+ return;
696
+ }
697
+ }
693
698
  const scrollBottom = scroll + scrollLength;
694
699
  let startNoBuffer = null;
695
700
  let startBuffered = null;
@@ -783,6 +788,14 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
783
788
  endBuffered,
784
789
  endNoBuffer
785
790
  });
791
+ const nextTop = Math.ceil(startBuffered ? positions.get(startBufferedId) + scrollBuffer : 0);
792
+ const nextBottom = Math.floor(
793
+ endBuffered ? (positions.get(getId(endBuffered + 1)) || 0) - scrollLength - scrollBuffer : 0
794
+ );
795
+ refState.current.scrollForNextCalculateItemsInView = nextTop >= 0 && nextBottom >= 0 ? {
796
+ top: nextTop,
797
+ bottom: nextBottom
798
+ } : void 0;
786
799
  if (startBuffered !== null && endBuffered !== null) {
787
800
  const prevNumContainers = ctx.values.get("numContainers");
788
801
  let numContainers = prevNumContainers;
@@ -825,7 +838,7 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
825
838
  numContainers++;
826
839
  set$(ctx, `containerItemKey${containerId}`, id);
827
840
  const index = (_c2 = refState.current) == null ? void 0 : _c2.indexByKey.get(id);
828
- set$(ctx, `containerItemData${furthestIndex}`, data2[index]);
841
+ set$(ctx, `containerItemData${containerId}`, data2[index]);
829
842
  set$(ctx, `containerPosition${containerId}`, POSITION_OUT_OF_VIEW);
830
843
  set$(ctx, `containerColumn${containerId}`, -1);
831
844
  if (__DEV__ && numContainers > peek$(ctx, "numContainersPooled")) {
@@ -875,6 +888,12 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
875
888
  }
876
889
  }
877
890
  }
891
+ if (layoutsPending.size > 0) {
892
+ for (const containerId of layoutsPending) {
893
+ set$(ctx, `containerDidLayout${containerId}`, true);
894
+ }
895
+ layoutsPending.clear();
896
+ }
878
897
  if (refState.current.viewabilityConfigCallbackPairs) {
879
898
  updateViewableItems(
880
899
  refState.current,
@@ -956,6 +975,33 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
956
975
  }
957
976
  }
958
977
  };
978
+ const resetContainers = () => {
979
+ const state = refState.current;
980
+ if (state) {
981
+ if (data.length > state.data.length) {
982
+ state.isEndReached = false;
983
+ }
984
+ refState.current.scrollForNextCalculateItemsInView = void 0;
985
+ state.data = data;
986
+ const numContainers = peek$(ctx, "numContainers");
987
+ for (let i = 0; i < numContainers; i++) {
988
+ const itemKey = peek$(ctx, `containerItemKey${i}`);
989
+ if (!keyExtractorProp || itemKey && state.indexByKey.get(itemKey) === void 0) {
990
+ set$(ctx, `containerItemKey${i}`, void 0);
991
+ set$(ctx, `containerPosition${i}`, POSITION_OUT_OF_VIEW);
992
+ set$(ctx, `containerColumn${i}`, -1);
993
+ }
994
+ }
995
+ if (!keyExtractorProp) {
996
+ state.sizes.clear();
997
+ state.positions;
998
+ }
999
+ calculateItemsInView(state.scrollVelocity);
1000
+ doMaintainScrollAtEnd(false);
1001
+ checkAtTop();
1002
+ checkAtBottom();
1003
+ }
1004
+ };
959
1005
  const isFirst = !refState.current.renderItem;
960
1006
  if (isFirst || data !== refState.current.data || numColumnsProp !== peek$(ctx, "numColumns")) {
961
1007
  if (!keyExtractorProp && !isFirst && data !== refState.current.data) {
@@ -989,40 +1035,24 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
989
1035
  }
990
1036
  }
991
1037
  addTotalSize(null, totalSize, totalSizeBelowIndex);
1038
+ }
1039
+ useEffect(() => {
992
1040
  if (!isFirst) {
993
- if (data.length > refState.current.data.length) {
994
- refState.current.isEndReached = false;
995
- }
996
- refState.current.data = data;
997
- const numContainers = peek$(ctx, "numContainers");
998
- for (let i = 0; i < numContainers; i++) {
999
- const itemKey = peek$(ctx, `containerItemKey${i}`);
1000
- if (!keyExtractorProp || itemKey && ((_a = refState.current) == null ? void 0 : _a.indexByKey.get(itemKey)) === void 0) {
1001
- set$(ctx, `containerItemKey${i}`, void 0);
1002
- set$(ctx, `containerPosition${i}`, POSITION_OUT_OF_VIEW);
1003
- set$(ctx, `containerColumn${i}`, -1);
1004
- }
1005
- }
1006
- if (!keyExtractorProp) {
1007
- refState.current.sizes.clear();
1008
- refState.current.positions;
1009
- }
1010
- setTimeout(() => {
1011
- calculateItemsInView(refState.current.scrollVelocity);
1012
- doMaintainScrollAtEnd(false);
1013
- checkAtTop();
1014
- checkAtBottom();
1015
- }, 0);
1041
+ resetContainers();
1016
1042
  }
1017
- }
1043
+ }, [isFirst, data, numColumnsProp]);
1018
1044
  refState.current.renderItem = renderItem;
1019
- set$(ctx, "lastItemKey", getId(data[data.length - 1]));
1020
- set$(ctx, "numColumns", numColumnsProp);
1021
- set$(
1022
- ctx,
1023
- "stylePaddingTop",
1024
- (_e = (_d = (_b = StyleSheet.flatten(style)) == null ? void 0 : _b.paddingTop) != null ? _d : (_c = StyleSheet.flatten(contentContainerStyle)) == null ? void 0 : _c.paddingTop) != null ? _e : 0
1025
- );
1045
+ const lastItemKey = getId(data[data.length - 1]);
1046
+ const stylePaddingTop = (_d = (_c = (_a = StyleSheet.flatten(style)) == null ? void 0 : _a.paddingTop) != null ? _c : (_b = StyleSheet.flatten(contentContainerStyle)) == null ? void 0 : _b.paddingTop) != null ? _d : 0;
1047
+ const initalizeStateVars = () => {
1048
+ set$(ctx, "lastItemKey", lastItemKey);
1049
+ set$(ctx, "numColumns", numColumnsProp);
1050
+ set$(ctx, "stylePaddingTop", stylePaddingTop);
1051
+ };
1052
+ if (isFirst) {
1053
+ initalizeStateVars();
1054
+ }
1055
+ useEffect(initalizeStateVars, [lastItemKey, numColumnsProp, stylePaddingTop]);
1026
1056
  const getRenderedItem = useCallback((key, containerId) => {
1027
1057
  var _a2, _b2;
1028
1058
  const state = refState.current;
@@ -1090,7 +1120,7 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
1090
1120
  }
1091
1121
  };
1092
1122
  run();
1093
- listen$(ctx, signal, run);
1123
+ return listen$(ctx, signal, run);
1094
1124
  }, []);
1095
1125
  };
1096
1126
  const useRecyclingState = (valueOrFun) => {
@@ -1144,6 +1174,10 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
1144
1174
  const numColumns = peek$(ctx, "numColumns");
1145
1175
  const row = Math.floor(index / numColumns);
1146
1176
  const prevSize = getRowHeight(row);
1177
+ const measured = peek$(ctx, `containerDidLayout${containerId}`);
1178
+ if (!measured) {
1179
+ state.layoutsPending.add(containerId);
1180
+ }
1147
1181
  if (!prevSize || Math.abs(prevSize - size) > 0.5) {
1148
1182
  let diff;
1149
1183
  if (numColumns > 1) {
@@ -1181,6 +1215,7 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
1181
1215
  );
1182
1216
  }, 1e3);
1183
1217
  }
1218
+ refState.current.scrollForNextCalculateItemsInView = void 0;
1184
1219
  addTotalSize(itemKey, diff, 0);
1185
1220
  doMaintainScrollAtEnd(true);
1186
1221
  const scrollVelocity = state.scrollVelocity;
@@ -1194,6 +1229,8 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
1194
1229
  calculateItemsInView(state.scrollVelocity);
1195
1230
  }
1196
1231
  }
1232
+ } else {
1233
+ set$(ctx, `containerDidLayout${containerId}`, true);
1197
1234
  }
1198
1235
  }, []);
1199
1236
  const handleScrollDebounced = useCallback((velocity) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@legendapp/list",
3
- "version": "0.6.2",
3
+ "version": "0.6.3",
4
4
  "description": "legend-list",
5
5
  "sideEffects": false,
6
6
  "private": false,