@legendapp/list 2.0.6 → 2.0.8
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/.DS_Store +0 -0
- package/CHANGELOG.md +7 -0
- package/index.d.mts +1 -0
- package/index.d.ts +1 -0
- package/index.js +17 -16
- package/index.mjs +17 -16
- package/package.json +1 -1
package/.DS_Store
ADDED
|
Binary file
|
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## 2.0.8
|
|
2
|
+
- Fix: Data changing sometimes left blank spaces because it was ignoring scroll
|
|
3
|
+
- Fix: Toggling between empty and non-empty causing maintainVisibleContentPosition issues
|
|
4
|
+
|
|
5
|
+
## 2.0.7
|
|
6
|
+
- Fix: Layout not working on react-native-macos because of transform instead of position
|
|
7
|
+
|
|
1
8
|
## 2.0.6
|
|
2
9
|
- Fix: updateItemPositions edge case with items multiple screen heights long was breaking the loop too early
|
|
3
10
|
|
package/index.d.mts
CHANGED
|
@@ -331,6 +331,7 @@ interface InternalState {
|
|
|
331
331
|
minIndexSizeChanged: number | undefined;
|
|
332
332
|
queuedInitialLayout?: boolean | undefined;
|
|
333
333
|
queuedCalculateItemsInView: number | undefined;
|
|
334
|
+
dataChangeNeedsScrollUpdate: boolean;
|
|
334
335
|
lastBatchingAction: number;
|
|
335
336
|
ignoreScrollFromMVCP?: {
|
|
336
337
|
lt?: number;
|
package/index.d.ts
CHANGED
|
@@ -331,6 +331,7 @@ interface InternalState {
|
|
|
331
331
|
minIndexSizeChanged: number | undefined;
|
|
332
332
|
queuedInitialLayout?: boolean | undefined;
|
|
333
333
|
queuedCalculateItemsInView: number | undefined;
|
|
334
|
+
dataChangeNeedsScrollUpdate: boolean;
|
|
334
335
|
lastBatchingAction: number;
|
|
335
336
|
ignoreScrollFromMVCP?: {
|
|
336
337
|
lt?: number;
|
package/index.js
CHANGED
|
@@ -266,17 +266,13 @@ var PositionViewAnimated = typedMemo(function PositionView2({
|
|
|
266
266
|
const position$ = useValue$(`containerPosition${id}`, {
|
|
267
267
|
getValue: (v) => v != null ? v : POSITION_OUT_OF_VIEW
|
|
268
268
|
});
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
{
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
],
|
|
277
|
-
...rest
|
|
278
|
-
}
|
|
279
|
-
);
|
|
269
|
+
let position;
|
|
270
|
+
if (reactNative.Platform.OS === "ios" || reactNative.Platform.OS === "android") {
|
|
271
|
+
position = horizontal ? { transform: [{ translateX: position$ }] } : { transform: [{ translateY: position$ }] };
|
|
272
|
+
} else {
|
|
273
|
+
position = horizontal ? { left: position$ } : { top: position$ };
|
|
274
|
+
}
|
|
275
|
+
return /* @__PURE__ */ React2__namespace.createElement(reactNative.Animated.View, { ref: refView, style: [style, position], ...rest });
|
|
280
276
|
});
|
|
281
277
|
var PositionViewSticky = typedMemo(function PositionViewSticky2({
|
|
282
278
|
id,
|
|
@@ -824,7 +820,7 @@ var ListComponent = typedMemo(function ListComponent2({
|
|
|
824
820
|
],
|
|
825
821
|
contentOffset: initialContentOffset ? horizontal ? { x: initialContentOffset, y: 0 } : { x: 0, y: initialContentOffset } : void 0,
|
|
826
822
|
horizontal,
|
|
827
|
-
maintainVisibleContentPosition: maintainVisibleContentPosition
|
|
823
|
+
maintainVisibleContentPosition: maintainVisibleContentPosition ? { minIndexForVisible: 0 } : void 0,
|
|
828
824
|
onLayout,
|
|
829
825
|
onScroll: onScroll2,
|
|
830
826
|
ref: refScrollView,
|
|
@@ -835,7 +831,7 @@ var ListComponent = typedMemo(function ListComponent2({
|
|
|
835
831
|
ENABLE_DEVMODE ? /* @__PURE__ */ React2__namespace.createElement(PaddingDevMode, null) : /* @__PURE__ */ React2__namespace.createElement(Padding, null),
|
|
836
832
|
ListHeaderComponent && /* @__PURE__ */ React2__namespace.createElement(reactNative.View, { onLayout: onLayoutHeaderSync, ref: refHeader, style: ListHeaderComponentStyle }, getComponent(ListHeaderComponent)),
|
|
837
833
|
ListEmptyComponent && getComponent(ListEmptyComponent),
|
|
838
|
-
canRender && /* @__PURE__ */ React2__namespace.createElement(
|
|
834
|
+
canRender && !ListEmptyComponent && /* @__PURE__ */ React2__namespace.createElement(
|
|
839
835
|
Containers,
|
|
840
836
|
{
|
|
841
837
|
getRenderedItem: getRenderedItem2,
|
|
@@ -1869,7 +1865,7 @@ function calculateItemsInView(ctx, state, params = {}) {
|
|
|
1869
1865
|
const scrollTopBuffered = scroll - scrollBufferTop;
|
|
1870
1866
|
const scrollBottom = scroll + scrollLength + (scroll < 0 ? -scroll : 0);
|
|
1871
1867
|
const scrollBottomBuffered = scrollBottom + scrollBufferBottom;
|
|
1872
|
-
if (scrollForNextCalculateItemsInView) {
|
|
1868
|
+
if (!dataChanged && scrollForNextCalculateItemsInView) {
|
|
1873
1869
|
const { top, bottom } = scrollForNextCalculateItemsInView;
|
|
1874
1870
|
if (scrollTopBuffered > top && scrollBottomBuffered < bottom) {
|
|
1875
1871
|
return;
|
|
@@ -1892,7 +1888,7 @@ function calculateItemsInView(ctx, state, params = {}) {
|
|
|
1892
1888
|
let startBufferedId = null;
|
|
1893
1889
|
let endNoBuffer = null;
|
|
1894
1890
|
let endBuffered = null;
|
|
1895
|
-
let loopStart = startBufferedIdOrig ? indexByKey.get(startBufferedIdOrig) || 0 : 0;
|
|
1891
|
+
let loopStart = !dataChanged && startBufferedIdOrig ? indexByKey.get(startBufferedIdOrig) || 0 : 0;
|
|
1896
1892
|
for (let i = loopStart; i >= 0; i--) {
|
|
1897
1893
|
const id = (_b = idCache.get(i)) != null ? _b : getId(state, i);
|
|
1898
1894
|
const top = positions.get(id);
|
|
@@ -2371,10 +2367,11 @@ function updateScroll(ctx, state, newScroll) {
|
|
|
2371
2367
|
state.scrollPrevTime = state.scrollTime;
|
|
2372
2368
|
state.scroll = newScroll;
|
|
2373
2369
|
state.scrollTime = currentTime;
|
|
2374
|
-
if (Math.abs(state.scroll - state.scrollPrev) > 2) {
|
|
2370
|
+
if (state.dataChangeNeedsScrollUpdate || Math.abs(state.scroll - state.scrollPrev) > 2) {
|
|
2375
2371
|
calculateItemsInView(ctx, state);
|
|
2376
2372
|
checkAtBottom(ctx, state);
|
|
2377
2373
|
checkAtTop(state);
|
|
2374
|
+
state.dataChangeNeedsScrollUpdate = false;
|
|
2378
2375
|
}
|
|
2379
2376
|
}
|
|
2380
2377
|
|
|
@@ -2695,6 +2692,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2695
2692
|
columns: /* @__PURE__ */ new Map(),
|
|
2696
2693
|
containerItemKeys: /* @__PURE__ */ new Set(),
|
|
2697
2694
|
containerItemTypes: /* @__PURE__ */ new Map(),
|
|
2695
|
+
dataChangeNeedsScrollUpdate: false,
|
|
2698
2696
|
enableScrollForNextCalculateItemsInView: true,
|
|
2699
2697
|
endBuffered: -1,
|
|
2700
2698
|
endNoBuffer: -1,
|
|
@@ -2745,6 +2743,9 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2745
2743
|
const state = refState.current;
|
|
2746
2744
|
const isFirst = !state.props.renderItem;
|
|
2747
2745
|
const didDataChange = state.props.data !== dataProp;
|
|
2746
|
+
if (didDataChange) {
|
|
2747
|
+
state.dataChangeNeedsScrollUpdate = true;
|
|
2748
|
+
}
|
|
2748
2749
|
const throttleScrollFn = scrollEventThrottle && onScrollProp ? useThrottledOnScroll(onScrollProp, scrollEventThrottle) : onScrollProp;
|
|
2749
2750
|
state.props = {
|
|
2750
2751
|
alignItemsAtEnd,
|
package/index.mjs
CHANGED
|
@@ -245,17 +245,13 @@ var PositionViewAnimated = typedMemo(function PositionView2({
|
|
|
245
245
|
const position$ = useValue$(`containerPosition${id}`, {
|
|
246
246
|
getValue: (v) => v != null ? v : POSITION_OUT_OF_VIEW
|
|
247
247
|
});
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
{
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
],
|
|
256
|
-
...rest
|
|
257
|
-
}
|
|
258
|
-
);
|
|
248
|
+
let position;
|
|
249
|
+
if (Platform.OS === "ios" || Platform.OS === "android") {
|
|
250
|
+
position = horizontal ? { transform: [{ translateX: position$ }] } : { transform: [{ translateY: position$ }] };
|
|
251
|
+
} else {
|
|
252
|
+
position = horizontal ? { left: position$ } : { top: position$ };
|
|
253
|
+
}
|
|
254
|
+
return /* @__PURE__ */ React2.createElement(Animated.View, { ref: refView, style: [style, position], ...rest });
|
|
259
255
|
});
|
|
260
256
|
var PositionViewSticky = typedMemo(function PositionViewSticky2({
|
|
261
257
|
id,
|
|
@@ -803,7 +799,7 @@ var ListComponent = typedMemo(function ListComponent2({
|
|
|
803
799
|
],
|
|
804
800
|
contentOffset: initialContentOffset ? horizontal ? { x: initialContentOffset, y: 0 } : { x: 0, y: initialContentOffset } : void 0,
|
|
805
801
|
horizontal,
|
|
806
|
-
maintainVisibleContentPosition: maintainVisibleContentPosition
|
|
802
|
+
maintainVisibleContentPosition: maintainVisibleContentPosition ? { minIndexForVisible: 0 } : void 0,
|
|
807
803
|
onLayout,
|
|
808
804
|
onScroll: onScroll2,
|
|
809
805
|
ref: refScrollView,
|
|
@@ -814,7 +810,7 @@ var ListComponent = typedMemo(function ListComponent2({
|
|
|
814
810
|
ENABLE_DEVMODE ? /* @__PURE__ */ React2.createElement(PaddingDevMode, null) : /* @__PURE__ */ React2.createElement(Padding, null),
|
|
815
811
|
ListHeaderComponent && /* @__PURE__ */ React2.createElement(View, { onLayout: onLayoutHeaderSync, ref: refHeader, style: ListHeaderComponentStyle }, getComponent(ListHeaderComponent)),
|
|
816
812
|
ListEmptyComponent && getComponent(ListEmptyComponent),
|
|
817
|
-
canRender && /* @__PURE__ */ React2.createElement(
|
|
813
|
+
canRender && !ListEmptyComponent && /* @__PURE__ */ React2.createElement(
|
|
818
814
|
Containers,
|
|
819
815
|
{
|
|
820
816
|
getRenderedItem: getRenderedItem2,
|
|
@@ -1848,7 +1844,7 @@ function calculateItemsInView(ctx, state, params = {}) {
|
|
|
1848
1844
|
const scrollTopBuffered = scroll - scrollBufferTop;
|
|
1849
1845
|
const scrollBottom = scroll + scrollLength + (scroll < 0 ? -scroll : 0);
|
|
1850
1846
|
const scrollBottomBuffered = scrollBottom + scrollBufferBottom;
|
|
1851
|
-
if (scrollForNextCalculateItemsInView) {
|
|
1847
|
+
if (!dataChanged && scrollForNextCalculateItemsInView) {
|
|
1852
1848
|
const { top, bottom } = scrollForNextCalculateItemsInView;
|
|
1853
1849
|
if (scrollTopBuffered > top && scrollBottomBuffered < bottom) {
|
|
1854
1850
|
return;
|
|
@@ -1871,7 +1867,7 @@ function calculateItemsInView(ctx, state, params = {}) {
|
|
|
1871
1867
|
let startBufferedId = null;
|
|
1872
1868
|
let endNoBuffer = null;
|
|
1873
1869
|
let endBuffered = null;
|
|
1874
|
-
let loopStart = startBufferedIdOrig ? indexByKey.get(startBufferedIdOrig) || 0 : 0;
|
|
1870
|
+
let loopStart = !dataChanged && startBufferedIdOrig ? indexByKey.get(startBufferedIdOrig) || 0 : 0;
|
|
1875
1871
|
for (let i = loopStart; i >= 0; i--) {
|
|
1876
1872
|
const id = (_b = idCache.get(i)) != null ? _b : getId(state, i);
|
|
1877
1873
|
const top = positions.get(id);
|
|
@@ -2350,10 +2346,11 @@ function updateScroll(ctx, state, newScroll) {
|
|
|
2350
2346
|
state.scrollPrevTime = state.scrollTime;
|
|
2351
2347
|
state.scroll = newScroll;
|
|
2352
2348
|
state.scrollTime = currentTime;
|
|
2353
|
-
if (Math.abs(state.scroll - state.scrollPrev) > 2) {
|
|
2349
|
+
if (state.dataChangeNeedsScrollUpdate || Math.abs(state.scroll - state.scrollPrev) > 2) {
|
|
2354
2350
|
calculateItemsInView(ctx, state);
|
|
2355
2351
|
checkAtBottom(ctx, state);
|
|
2356
2352
|
checkAtTop(state);
|
|
2353
|
+
state.dataChangeNeedsScrollUpdate = false;
|
|
2357
2354
|
}
|
|
2358
2355
|
}
|
|
2359
2356
|
|
|
@@ -2674,6 +2671,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2674
2671
|
columns: /* @__PURE__ */ new Map(),
|
|
2675
2672
|
containerItemKeys: /* @__PURE__ */ new Set(),
|
|
2676
2673
|
containerItemTypes: /* @__PURE__ */ new Map(),
|
|
2674
|
+
dataChangeNeedsScrollUpdate: false,
|
|
2677
2675
|
enableScrollForNextCalculateItemsInView: true,
|
|
2678
2676
|
endBuffered: -1,
|
|
2679
2677
|
endNoBuffer: -1,
|
|
@@ -2724,6 +2722,9 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2724
2722
|
const state = refState.current;
|
|
2725
2723
|
const isFirst = !state.props.renderItem;
|
|
2726
2724
|
const didDataChange = state.props.data !== dataProp;
|
|
2725
|
+
if (didDataChange) {
|
|
2726
|
+
state.dataChangeNeedsScrollUpdate = true;
|
|
2727
|
+
}
|
|
2727
2728
|
const throttleScrollFn = scrollEventThrottle && onScrollProp ? useThrottledOnScroll(onScrollProp, scrollEventThrottle) : onScrollProp;
|
|
2728
2729
|
state.props = {
|
|
2729
2730
|
alignItemsAtEnd,
|
package/package.json
CHANGED