@legendapp/list 1.0.16 → 1.0.17

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/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 1.0.17
2
+ - Fix: initialScrollIndex not taking header component size into account
3
+ - Fix: PaddingAndAdjust for ListHeaderComponent
4
+ - Fix: ignore alignItemsAtEnd when the list is empty
5
+
1
6
  ## 1.0.16
2
7
  - Fix: isAtEnd was going to false when overscrolling
3
8
  - Fix: refreshControl not being top padded correctly
package/index.js CHANGED
@@ -691,7 +691,7 @@ var ListComponent = typedMemo(function ListComponent2({
691
691
  contentOffset: initialContentOffset ? horizontal ? { x: initialContentOffset, y: 0 } : { x: 0, y: initialContentOffset } : void 0,
692
692
  ref: refScrollView
693
693
  },
694
- !ListEmptyComponent && (ENABLE_DEVMODE ? /* @__PURE__ */ React2__namespace.createElement(PaddingAndAdjustDevMode, null) : /* @__PURE__ */ React2__namespace.createElement(PaddingAndAdjust, null)),
694
+ ENABLE_DEVMODE ? /* @__PURE__ */ React2__namespace.createElement(PaddingAndAdjustDevMode, null) : /* @__PURE__ */ React2__namespace.createElement(PaddingAndAdjust, null),
695
695
  ListHeaderComponent && /* @__PURE__ */ React2__namespace.createElement(
696
696
  ListHeaderComponentContainer,
697
697
  {
@@ -1021,6 +1021,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1021
1021
  estimatedItemSize: estimatedItemSizeProp,
1022
1022
  getEstimatedItemSize,
1023
1023
  suggestEstimatedItemSize,
1024
+ ListHeaderComponent,
1024
1025
  ListEmptyComponent,
1025
1026
  onItemSizeChanged,
1026
1027
  refScrollView,
@@ -1732,10 +1733,13 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1732
1733
  };
1733
1734
  const updateAlignItemsPaddingTop = () => {
1734
1735
  if (alignItemsAtEnd) {
1735
- const { scrollLength } = refState.current;
1736
- const contentSize = getContentSize(ctx);
1737
- const paddingTop = Math.max(0, Math.floor(scrollLength - contentSize));
1738
- setPaddingTop({ alignItemsPaddingTop: paddingTop });
1736
+ const { data, scrollLength } = refState.current;
1737
+ let alignItemsPaddingTop = 0;
1738
+ if ((data == null ? void 0 : data.length) > 0) {
1739
+ const contentSize = getContentSize(ctx);
1740
+ alignItemsPaddingTop = Math.max(0, Math.floor(scrollLength - contentSize));
1741
+ }
1742
+ setPaddingTop({ alignItemsPaddingTop });
1739
1743
  }
1740
1744
  };
1741
1745
  const finishScrollTo = () => {
@@ -2086,6 +2090,18 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
2086
2090
  refState.current.previousTotalSize = peek$(ctx, "totalSize");
2087
2091
  calcTotalSizesAndPositions({ forgetPositions: false });
2088
2092
  }
2093
+ React2.useEffect(() => {
2094
+ if (initialScrollIndex && ListHeaderComponent) {
2095
+ const dispose = listen$(ctx, "headerSize", (size) => {
2096
+ if (size > 0) {
2097
+ scrollToIndex({ index: initialScrollIndex, animated: false });
2098
+ dispose == null ? void 0 : dispose();
2099
+ }
2100
+ });
2101
+ setTimeout(dispose, 0);
2102
+ return dispose;
2103
+ }
2104
+ }, []);
2089
2105
  React2.useEffect(() => {
2090
2106
  const didAllocateContainers = doInitialAllocateContainers();
2091
2107
  if (!didAllocateContainers) {
@@ -2513,6 +2529,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
2513
2529
  recycleItems,
2514
2530
  alignItemsAtEnd,
2515
2531
  ListEmptyComponent: dataProp.length === 0 ? ListEmptyComponent : void 0,
2532
+ ListHeaderComponent,
2516
2533
  maintainVisibleContentPosition,
2517
2534
  scrollEventThrottle: reactNative.Platform.OS === "web" ? 16 : void 0,
2518
2535
  waitForInitialLayout,
package/index.mjs CHANGED
@@ -670,7 +670,7 @@ var ListComponent = typedMemo(function ListComponent2({
670
670
  contentOffset: initialContentOffset ? horizontal ? { x: initialContentOffset, y: 0 } : { x: 0, y: initialContentOffset } : void 0,
671
671
  ref: refScrollView
672
672
  },
673
- !ListEmptyComponent && (ENABLE_DEVMODE ? /* @__PURE__ */ React2.createElement(PaddingAndAdjustDevMode, null) : /* @__PURE__ */ React2.createElement(PaddingAndAdjust, null)),
673
+ ENABLE_DEVMODE ? /* @__PURE__ */ React2.createElement(PaddingAndAdjustDevMode, null) : /* @__PURE__ */ React2.createElement(PaddingAndAdjust, null),
674
674
  ListHeaderComponent && /* @__PURE__ */ React2.createElement(
675
675
  ListHeaderComponentContainer,
676
676
  {
@@ -1000,6 +1000,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1000
1000
  estimatedItemSize: estimatedItemSizeProp,
1001
1001
  getEstimatedItemSize,
1002
1002
  suggestEstimatedItemSize,
1003
+ ListHeaderComponent,
1003
1004
  ListEmptyComponent,
1004
1005
  onItemSizeChanged,
1005
1006
  refScrollView,
@@ -1711,10 +1712,13 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1711
1712
  };
1712
1713
  const updateAlignItemsPaddingTop = () => {
1713
1714
  if (alignItemsAtEnd) {
1714
- const { scrollLength } = refState.current;
1715
- const contentSize = getContentSize(ctx);
1716
- const paddingTop = Math.max(0, Math.floor(scrollLength - contentSize));
1717
- setPaddingTop({ alignItemsPaddingTop: paddingTop });
1715
+ const { data, scrollLength } = refState.current;
1716
+ let alignItemsPaddingTop = 0;
1717
+ if ((data == null ? void 0 : data.length) > 0) {
1718
+ const contentSize = getContentSize(ctx);
1719
+ alignItemsPaddingTop = Math.max(0, Math.floor(scrollLength - contentSize));
1720
+ }
1721
+ setPaddingTop({ alignItemsPaddingTop });
1718
1722
  }
1719
1723
  };
1720
1724
  const finishScrollTo = () => {
@@ -2065,6 +2069,18 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
2065
2069
  refState.current.previousTotalSize = peek$(ctx, "totalSize");
2066
2070
  calcTotalSizesAndPositions({ forgetPositions: false });
2067
2071
  }
2072
+ useEffect(() => {
2073
+ if (initialScrollIndex && ListHeaderComponent) {
2074
+ const dispose = listen$(ctx, "headerSize", (size) => {
2075
+ if (size > 0) {
2076
+ scrollToIndex({ index: initialScrollIndex, animated: false });
2077
+ dispose == null ? void 0 : dispose();
2078
+ }
2079
+ });
2080
+ setTimeout(dispose, 0);
2081
+ return dispose;
2082
+ }
2083
+ }, []);
2068
2084
  useEffect(() => {
2069
2085
  const didAllocateContainers = doInitialAllocateContainers();
2070
2086
  if (!didAllocateContainers) {
@@ -2492,6 +2508,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
2492
2508
  recycleItems,
2493
2509
  alignItemsAtEnd,
2494
2510
  ListEmptyComponent: dataProp.length === 0 ? ListEmptyComponent : void 0,
2511
+ ListHeaderComponent,
2495
2512
  maintainVisibleContentPosition,
2496
2513
  scrollEventThrottle: Platform.OS === "web" ? 16 : void 0,
2497
2514
  waitForInitialLayout,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@legendapp/list",
3
- "version": "1.0.16",
3
+ "version": "1.0.17",
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,