@legendapp/list 2.0.11 → 2.0.12
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 +4 -0
- package/animated.d.mts +2 -2
- package/animated.d.ts +2 -2
- package/index.d.mts +1 -0
- package/index.d.ts +1 -0
- package/index.js +20 -14
- package/index.mjs +20 -14
- package/package.json +1 -1
- package/reanimated.d.mts +5 -4
- package/reanimated.d.ts +5 -4
- package/reanimated.js +24 -6
- package/reanimated.mjs +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
## 2.0.12
|
|
2
|
+
- Fix: Scroll velocity calculation was sometimes incorrect when item sizes were very different from estimate
|
|
3
|
+
- Fix: onScroll while scrolling was updating positions without maintainVisibleContentPosition calculations, which was breaking scroll position maintenance
|
|
4
|
+
|
|
1
5
|
## 2.0.11
|
|
2
6
|
- Fix: Missing React import in a file
|
|
3
7
|
|
package/animated.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import * as React$1 from 'react';
|
|
2
1
|
import * as _legendapp_list from '@legendapp/list';
|
|
2
|
+
import * as React from 'react';
|
|
3
3
|
import { Animated } from 'react-native';
|
|
4
4
|
|
|
5
|
-
declare const AnimatedLegendList: Animated.AnimatedComponent<(<T>(props: _legendapp_list.LegendListProps<T> & React
|
|
5
|
+
declare const AnimatedLegendList: Animated.AnimatedComponent<(<T>(props: _legendapp_list.LegendListProps<T> & React.RefAttributes<_legendapp_list.LegendListRef>) => React.ReactNode) & {
|
|
6
6
|
displayName?: string;
|
|
7
7
|
}>;
|
|
8
8
|
|
package/animated.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import * as React$1 from 'react';
|
|
2
1
|
import * as _legendapp_list from '@legendapp/list';
|
|
2
|
+
import * as React from 'react';
|
|
3
3
|
import { Animated } from 'react-native';
|
|
4
4
|
|
|
5
|
-
declare const AnimatedLegendList: Animated.AnimatedComponent<(<T>(props: _legendapp_list.LegendListProps<T> & React
|
|
5
|
+
declare const AnimatedLegendList: Animated.AnimatedComponent<(<T>(props: _legendapp_list.LegendListProps<T> & React.RefAttributes<_legendapp_list.LegendListRef>) => React.ReactNode) & {
|
|
6
6
|
displayName?: string;
|
|
7
7
|
}>;
|
|
8
8
|
|
package/index.d.mts
CHANGED
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -695,7 +695,7 @@ function ScrollAdjust() {
|
|
|
695
695
|
}
|
|
696
696
|
function SnapWrapper({ ScrollComponent, ...props }) {
|
|
697
697
|
const [snapToOffsets] = useArr$(["snapToOffsets"]);
|
|
698
|
-
return /* @__PURE__ */ React2__namespace.
|
|
698
|
+
return /* @__PURE__ */ React2__namespace.createElement(ScrollComponent, { ...props, snapToOffsets });
|
|
699
699
|
}
|
|
700
700
|
|
|
701
701
|
// src/components/ListComponent.tsx
|
|
@@ -1889,7 +1889,6 @@ function calculateItemsInView(ctx, state, params = {}) {
|
|
|
1889
1889
|
const totalSize = peek$(ctx, "totalSize");
|
|
1890
1890
|
const topPad = peek$(ctx, "stylePaddingTop") + peek$(ctx, "headerSize");
|
|
1891
1891
|
const numColumns = peek$(ctx, "numColumns");
|
|
1892
|
-
const previousScrollAdjust = 0;
|
|
1893
1892
|
const { dataChanged, doMVCP } = params;
|
|
1894
1893
|
const speed = getScrollVelocity(state);
|
|
1895
1894
|
const scrollExtra = 0;
|
|
@@ -1903,7 +1902,7 @@ function calculateItemsInView(ctx, state, params = {}) {
|
|
|
1903
1902
|
);
|
|
1904
1903
|
scrollState = updatedOffset;
|
|
1905
1904
|
}
|
|
1906
|
-
const scrollAdjustPad = -
|
|
1905
|
+
const scrollAdjustPad = -topPad;
|
|
1907
1906
|
let scroll = scrollState + scrollExtra + scrollAdjustPad;
|
|
1908
1907
|
if (scroll + scrollLength > totalSize) {
|
|
1909
1908
|
scroll = Math.max(0, totalSize - scrollLength);
|
|
@@ -2415,13 +2414,6 @@ function onScroll(ctx, state, event) {
|
|
|
2415
2414
|
return;
|
|
2416
2415
|
}
|
|
2417
2416
|
const newScroll = event.nativeEvent.contentOffset[state.props.horizontal ? "x" : "y"];
|
|
2418
|
-
const ignoreScrollFromMVCP = state.ignoreScrollFromMVCP;
|
|
2419
|
-
if (ignoreScrollFromMVCP && !state.scrollingTo) {
|
|
2420
|
-
const { lt, gt } = ignoreScrollFromMVCP;
|
|
2421
|
-
if (lt && newScroll < lt || gt && newScroll > gt) {
|
|
2422
|
-
return;
|
|
2423
|
-
}
|
|
2424
|
-
}
|
|
2425
2417
|
state.scrollPending = newScroll;
|
|
2426
2418
|
updateScroll(ctx, state, newScroll);
|
|
2427
2419
|
onScrollProp == null ? void 0 : onScrollProp(event);
|
|
@@ -2431,9 +2423,17 @@ function updateScroll(ctx, state, newScroll) {
|
|
|
2431
2423
|
state.hasScrolled = true;
|
|
2432
2424
|
state.lastBatchingAction = Date.now();
|
|
2433
2425
|
const currentTime = Date.now();
|
|
2426
|
+
const adjust = state.scrollAdjustHandler.getAdjust();
|
|
2427
|
+
const lastHistoryAdjust = state.lastScrollAdjustForHistory;
|
|
2428
|
+
const adjustChanged = lastHistoryAdjust !== void 0 && Math.abs(adjust - lastHistoryAdjust) > 0.1;
|
|
2429
|
+
if (adjustChanged) {
|
|
2430
|
+
state.scrollHistory.length = 0;
|
|
2431
|
+
}
|
|
2432
|
+
state.lastScrollAdjustForHistory = adjust;
|
|
2434
2433
|
if (scrollingTo === void 0 && !(state.scrollHistory.length === 0 && newScroll === state.scroll)) {
|
|
2435
|
-
|
|
2436
|
-
|
|
2434
|
+
if (!adjustChanged) {
|
|
2435
|
+
state.scrollHistory.push({ scroll: newScroll, time: currentTime });
|
|
2436
|
+
}
|
|
2437
2437
|
}
|
|
2438
2438
|
if (state.scrollHistory.length > 5) {
|
|
2439
2439
|
state.scrollHistory.shift();
|
|
@@ -2442,8 +2442,15 @@ function updateScroll(ctx, state, newScroll) {
|
|
|
2442
2442
|
state.scrollPrevTime = state.scrollTime;
|
|
2443
2443
|
state.scroll = newScroll;
|
|
2444
2444
|
state.scrollTime = currentTime;
|
|
2445
|
+
const ignoreScrollFromMVCP = state.ignoreScrollFromMVCP;
|
|
2446
|
+
if (ignoreScrollFromMVCP && !state.scrollingTo) {
|
|
2447
|
+
const { lt, gt } = ignoreScrollFromMVCP;
|
|
2448
|
+
if (lt && newScroll < lt || gt && newScroll > gt) {
|
|
2449
|
+
return;
|
|
2450
|
+
}
|
|
2451
|
+
}
|
|
2445
2452
|
if (state.dataChangeNeedsScrollUpdate || Math.abs(state.scroll - state.scrollPrev) > 2) {
|
|
2446
|
-
calculateItemsInView(ctx, state);
|
|
2453
|
+
calculateItemsInView(ctx, state, { doMVCP: state.scrollingTo !== void 0 });
|
|
2447
2454
|
checkAtBottom(ctx, state);
|
|
2448
2455
|
checkAtTop(state);
|
|
2449
2456
|
state.dataChangeNeedsScrollUpdate = false;
|
|
@@ -2484,7 +2491,6 @@ function updateItemSize(ctx, state, itemKey, sizeObj) {
|
|
|
2484
2491
|
getFixedItemSize,
|
|
2485
2492
|
getItemType,
|
|
2486
2493
|
horizontal,
|
|
2487
|
-
maintainVisibleContentPosition,
|
|
2488
2494
|
suggestEstimatedItemSize,
|
|
2489
2495
|
onItemSizeChanged,
|
|
2490
2496
|
data,
|
package/index.mjs
CHANGED
|
@@ -674,7 +674,7 @@ function ScrollAdjust() {
|
|
|
674
674
|
}
|
|
675
675
|
function SnapWrapper({ ScrollComponent, ...props }) {
|
|
676
676
|
const [snapToOffsets] = useArr$(["snapToOffsets"]);
|
|
677
|
-
return /* @__PURE__ */
|
|
677
|
+
return /* @__PURE__ */ React2.createElement(ScrollComponent, { ...props, snapToOffsets });
|
|
678
678
|
}
|
|
679
679
|
|
|
680
680
|
// src/components/ListComponent.tsx
|
|
@@ -1868,7 +1868,6 @@ function calculateItemsInView(ctx, state, params = {}) {
|
|
|
1868
1868
|
const totalSize = peek$(ctx, "totalSize");
|
|
1869
1869
|
const topPad = peek$(ctx, "stylePaddingTop") + peek$(ctx, "headerSize");
|
|
1870
1870
|
const numColumns = peek$(ctx, "numColumns");
|
|
1871
|
-
const previousScrollAdjust = 0;
|
|
1872
1871
|
const { dataChanged, doMVCP } = params;
|
|
1873
1872
|
const speed = getScrollVelocity(state);
|
|
1874
1873
|
const scrollExtra = 0;
|
|
@@ -1882,7 +1881,7 @@ function calculateItemsInView(ctx, state, params = {}) {
|
|
|
1882
1881
|
);
|
|
1883
1882
|
scrollState = updatedOffset;
|
|
1884
1883
|
}
|
|
1885
|
-
const scrollAdjustPad = -
|
|
1884
|
+
const scrollAdjustPad = -topPad;
|
|
1886
1885
|
let scroll = scrollState + scrollExtra + scrollAdjustPad;
|
|
1887
1886
|
if (scroll + scrollLength > totalSize) {
|
|
1888
1887
|
scroll = Math.max(0, totalSize - scrollLength);
|
|
@@ -2394,13 +2393,6 @@ function onScroll(ctx, state, event) {
|
|
|
2394
2393
|
return;
|
|
2395
2394
|
}
|
|
2396
2395
|
const newScroll = event.nativeEvent.contentOffset[state.props.horizontal ? "x" : "y"];
|
|
2397
|
-
const ignoreScrollFromMVCP = state.ignoreScrollFromMVCP;
|
|
2398
|
-
if (ignoreScrollFromMVCP && !state.scrollingTo) {
|
|
2399
|
-
const { lt, gt } = ignoreScrollFromMVCP;
|
|
2400
|
-
if (lt && newScroll < lt || gt && newScroll > gt) {
|
|
2401
|
-
return;
|
|
2402
|
-
}
|
|
2403
|
-
}
|
|
2404
2396
|
state.scrollPending = newScroll;
|
|
2405
2397
|
updateScroll(ctx, state, newScroll);
|
|
2406
2398
|
onScrollProp == null ? void 0 : onScrollProp(event);
|
|
@@ -2410,9 +2402,17 @@ function updateScroll(ctx, state, newScroll) {
|
|
|
2410
2402
|
state.hasScrolled = true;
|
|
2411
2403
|
state.lastBatchingAction = Date.now();
|
|
2412
2404
|
const currentTime = Date.now();
|
|
2405
|
+
const adjust = state.scrollAdjustHandler.getAdjust();
|
|
2406
|
+
const lastHistoryAdjust = state.lastScrollAdjustForHistory;
|
|
2407
|
+
const adjustChanged = lastHistoryAdjust !== void 0 && Math.abs(adjust - lastHistoryAdjust) > 0.1;
|
|
2408
|
+
if (adjustChanged) {
|
|
2409
|
+
state.scrollHistory.length = 0;
|
|
2410
|
+
}
|
|
2411
|
+
state.lastScrollAdjustForHistory = adjust;
|
|
2413
2412
|
if (scrollingTo === void 0 && !(state.scrollHistory.length === 0 && newScroll === state.scroll)) {
|
|
2414
|
-
|
|
2415
|
-
|
|
2413
|
+
if (!adjustChanged) {
|
|
2414
|
+
state.scrollHistory.push({ scroll: newScroll, time: currentTime });
|
|
2415
|
+
}
|
|
2416
2416
|
}
|
|
2417
2417
|
if (state.scrollHistory.length > 5) {
|
|
2418
2418
|
state.scrollHistory.shift();
|
|
@@ -2421,8 +2421,15 @@ function updateScroll(ctx, state, newScroll) {
|
|
|
2421
2421
|
state.scrollPrevTime = state.scrollTime;
|
|
2422
2422
|
state.scroll = newScroll;
|
|
2423
2423
|
state.scrollTime = currentTime;
|
|
2424
|
+
const ignoreScrollFromMVCP = state.ignoreScrollFromMVCP;
|
|
2425
|
+
if (ignoreScrollFromMVCP && !state.scrollingTo) {
|
|
2426
|
+
const { lt, gt } = ignoreScrollFromMVCP;
|
|
2427
|
+
if (lt && newScroll < lt || gt && newScroll > gt) {
|
|
2428
|
+
return;
|
|
2429
|
+
}
|
|
2430
|
+
}
|
|
2424
2431
|
if (state.dataChangeNeedsScrollUpdate || Math.abs(state.scroll - state.scrollPrev) > 2) {
|
|
2425
|
-
calculateItemsInView(ctx, state);
|
|
2432
|
+
calculateItemsInView(ctx, state, { doMVCP: state.scrollingTo !== void 0 });
|
|
2426
2433
|
checkAtBottom(ctx, state);
|
|
2427
2434
|
checkAtTop(state);
|
|
2428
2435
|
state.dataChangeNeedsScrollUpdate = false;
|
|
@@ -2463,7 +2470,6 @@ function updateItemSize(ctx, state, itemKey, sizeObj) {
|
|
|
2463
2470
|
getFixedItemSize,
|
|
2464
2471
|
getItemType,
|
|
2465
2472
|
horizontal,
|
|
2466
|
-
maintainVisibleContentPosition,
|
|
2467
2473
|
suggestEstimatedItemSize,
|
|
2468
2474
|
onItemSizeChanged,
|
|
2469
2475
|
data,
|
package/package.json
CHANGED
package/reanimated.d.mts
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ComponentProps } from 'react';
|
|
2
3
|
import Animated from 'react-native-reanimated';
|
|
3
4
|
import { LegendListPropsBase, LegendListRef } from '@legendapp/list';
|
|
4
5
|
|
|
5
6
|
type KeysToOmit = "getEstimatedItemSize" | "getFixedItemSize" | "getItemType" | "keyExtractor" | "animatedProps" | "renderItem" | "onItemSizeChanged" | "itemsAreEqual" | "ItemSeparatorComponent";
|
|
6
7
|
type PropsBase<ItemT> = LegendListPropsBase<ItemT, ComponentProps<typeof Animated.ScrollView>>;
|
|
7
8
|
interface AnimatedLegendListPropsBase<ItemT> extends Omit<PropsBase<ItemT>, KeysToOmit> {
|
|
8
|
-
refScrollView?:
|
|
9
|
+
refScrollView?: React.Ref<Animated.ScrollView>;
|
|
9
10
|
}
|
|
10
11
|
type OtherAnimatedLegendListProps<ItemT> = Pick<PropsBase<ItemT>, KeysToOmit>;
|
|
11
12
|
type AnimatedLegendListProps<ItemT> = Omit<AnimatedLegendListPropsBase<ItemT>, "refLegendList" | "ref"> & OtherAnimatedLegendListProps<ItemT>;
|
|
12
13
|
type AnimatedLegendListDefinition = <ItemT>(props: AnimatedLegendListProps<ItemT> & {
|
|
13
|
-
ref?:
|
|
14
|
-
}) =>
|
|
14
|
+
ref?: React.Ref<LegendListRef>;
|
|
15
|
+
}) => React.ReactElement | null;
|
|
15
16
|
declare const AnimatedLegendList: AnimatedLegendListDefinition;
|
|
16
17
|
|
|
17
18
|
export { AnimatedLegendList, type AnimatedLegendListProps, type AnimatedLegendListPropsBase };
|
package/reanimated.d.ts
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ComponentProps } from 'react';
|
|
2
3
|
import Animated from 'react-native-reanimated';
|
|
3
4
|
import { LegendListPropsBase, LegendListRef } from '@legendapp/list';
|
|
4
5
|
|
|
5
6
|
type KeysToOmit = "getEstimatedItemSize" | "getFixedItemSize" | "getItemType" | "keyExtractor" | "animatedProps" | "renderItem" | "onItemSizeChanged" | "itemsAreEqual" | "ItemSeparatorComponent";
|
|
6
7
|
type PropsBase<ItemT> = LegendListPropsBase<ItemT, ComponentProps<typeof Animated.ScrollView>>;
|
|
7
8
|
interface AnimatedLegendListPropsBase<ItemT> extends Omit<PropsBase<ItemT>, KeysToOmit> {
|
|
8
|
-
refScrollView?:
|
|
9
|
+
refScrollView?: React.Ref<Animated.ScrollView>;
|
|
9
10
|
}
|
|
10
11
|
type OtherAnimatedLegendListProps<ItemT> = Pick<PropsBase<ItemT>, KeysToOmit>;
|
|
11
12
|
type AnimatedLegendListProps<ItemT> = Omit<AnimatedLegendListPropsBase<ItemT>, "refLegendList" | "ref"> & OtherAnimatedLegendListProps<ItemT>;
|
|
12
13
|
type AnimatedLegendListDefinition = <ItemT>(props: AnimatedLegendListProps<ItemT> & {
|
|
13
|
-
ref?:
|
|
14
|
-
}) =>
|
|
14
|
+
ref?: React.Ref<LegendListRef>;
|
|
15
|
+
}) => React.ReactElement | null;
|
|
15
16
|
declare const AnimatedLegendList: AnimatedLegendListDefinition;
|
|
16
17
|
|
|
17
18
|
export { AnimatedLegendList, type AnimatedLegendListProps, type AnimatedLegendListPropsBase };
|
package/reanimated.js
CHANGED
|
@@ -6,7 +6,25 @@ var list = require('@legendapp/list');
|
|
|
6
6
|
|
|
7
7
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
function _interopNamespace(e) {
|
|
10
|
+
if (e && e.__esModule) return e;
|
|
11
|
+
var n = Object.create(null);
|
|
12
|
+
if (e) {
|
|
13
|
+
Object.keys(e).forEach(function (k) {
|
|
14
|
+
if (k !== 'default') {
|
|
15
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
16
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: function () { return e[k]; }
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
n.default = e;
|
|
24
|
+
return Object.freeze(n);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
10
28
|
var Animated__default = /*#__PURE__*/_interopDefault(Animated);
|
|
11
29
|
|
|
12
30
|
// src/integrations/reanimated.tsx
|
|
@@ -36,7 +54,7 @@ var useCombinedRef = (...refs) => {
|
|
|
36
54
|
// src/integrations/reanimated.tsx
|
|
37
55
|
var typedMemo = React.memo;
|
|
38
56
|
var LegendListForwardedRef = typedMemo(
|
|
39
|
-
|
|
57
|
+
React__namespace.forwardRef(function LegendListForwardedRef2(props, ref) {
|
|
40
58
|
const { refLegendList, ...rest } = props;
|
|
41
59
|
const refFn = React.useCallback(
|
|
42
60
|
(r) => {
|
|
@@ -44,16 +62,16 @@ var LegendListForwardedRef = typedMemo(
|
|
|
44
62
|
},
|
|
45
63
|
[refLegendList]
|
|
46
64
|
);
|
|
47
|
-
return /* @__PURE__ */
|
|
65
|
+
return /* @__PURE__ */ React__namespace.createElement(list.LegendList, { ref: refFn, refScrollView: ref, ...rest });
|
|
48
66
|
})
|
|
49
67
|
);
|
|
50
68
|
var AnimatedLegendListComponent = Animated__default.default.createAnimatedComponent(LegendListForwardedRef);
|
|
51
69
|
var AnimatedLegendList = typedMemo(
|
|
52
|
-
|
|
70
|
+
React__namespace.forwardRef(function AnimatedLegendList2(props, ref) {
|
|
53
71
|
const { refScrollView, ...rest } = props;
|
|
54
|
-
const refLegendList =
|
|
72
|
+
const refLegendList = React__namespace.useRef(null);
|
|
55
73
|
const combinedRef = useCombinedRef(refLegendList, ref);
|
|
56
|
-
return /* @__PURE__ */
|
|
74
|
+
return /* @__PURE__ */ React__namespace.createElement(AnimatedLegendListComponent, { ref: refScrollView, refLegendList: combinedRef, ...rest });
|
|
57
75
|
})
|
|
58
76
|
);
|
|
59
77
|
|
package/reanimated.mjs
CHANGED