@legendapp/list 0.5.9 → 0.6.1
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/README.md +1 -6
- package/animated.d.mts +9 -0
- package/animated.d.ts +9 -0
- package/animated.js +9 -0
- package/animated.mjs +7 -0
- package/index.d.mts +27 -4
- package/index.d.ts +27 -4
- package/index.js +316 -191
- package/index.mjs +299 -174
- package/package.json +1 -1
- package/reanimated.d.mts +13 -0
- package/reanimated.d.ts +13 -0
- package/reanimated.js +47 -0
- package/reanimated.mjs +40 -0
package/README.md
CHANGED
|
@@ -67,12 +67,7 @@ There's not a lot of code here so hopefully it's easy to contribute. If you want
|
|
|
67
67
|
|
|
68
68
|
## TODO list
|
|
69
69
|
|
|
70
|
-
-
|
|
71
|
-
- Adjust scroll when item heights change above the viewable area so they don't jump
|
|
72
|
-
- A prop to start with items at the bottom like a chat interface, just needs to pad the top with screen height - items height
|
|
73
|
-
- Other important missing features from FlatList or other lists libraries
|
|
74
|
-
- Optimizations:
|
|
75
|
-
- Loop over only potentially changed items when adjusting heights rather than data array
|
|
70
|
+
See [Road to v1](https://github.com/LegendApp/legend-list/issues/28)
|
|
76
71
|
|
|
77
72
|
## Community
|
|
78
73
|
|
package/animated.d.mts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import * as _legendapp_list from '@legendapp/list';
|
|
3
|
+
import { Animated } from 'react-native';
|
|
4
|
+
|
|
5
|
+
declare const AnimatedLegendList: Animated.AnimatedComponent<(<T>(props: _legendapp_list.LegendListProps<T> & {
|
|
6
|
+
ref?: React.ForwardedRef<_legendapp_list.LegendListRef>;
|
|
7
|
+
}) => React.ReactElement)>;
|
|
8
|
+
|
|
9
|
+
export { AnimatedLegendList };
|
package/animated.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import * as _legendapp_list from '@legendapp/list';
|
|
3
|
+
import { Animated } from 'react-native';
|
|
4
|
+
|
|
5
|
+
declare const AnimatedLegendList: Animated.AnimatedComponent<(<T>(props: _legendapp_list.LegendListProps<T> & {
|
|
6
|
+
ref?: React.ForwardedRef<_legendapp_list.LegendListRef>;
|
|
7
|
+
}) => React.ReactElement)>;
|
|
8
|
+
|
|
9
|
+
export { AnimatedLegendList };
|
package/animated.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var list = require('@legendapp/list');
|
|
4
|
+
var reactNative = require('react-native');
|
|
5
|
+
|
|
6
|
+
// src/animated.tsx
|
|
7
|
+
var AnimatedLegendList = reactNative.Animated.createAnimatedComponent(list.LegendList);
|
|
8
|
+
|
|
9
|
+
exports.AnimatedLegendList = AnimatedLegendList;
|
package/animated.mjs
ADDED
package/index.d.mts
CHANGED
|
@@ -1,7 +1,20 @@
|
|
|
1
1
|
import { ComponentProps, ReactNode, ForwardedRef, ReactElement } from 'react';
|
|
2
2
|
import { ScrollView, StyleProp, ViewStyle, ScrollViewComponent, ScrollResponderMixin } from 'react-native';
|
|
3
|
+
import Animated from 'react-native-reanimated';
|
|
3
4
|
|
|
4
|
-
|
|
5
|
+
declare class ScrollAdjustHandler {
|
|
6
|
+
private ctx;
|
|
7
|
+
private appliedAdjust;
|
|
8
|
+
private pendingAdjust;
|
|
9
|
+
private busy;
|
|
10
|
+
private context;
|
|
11
|
+
private firstAdjust;
|
|
12
|
+
constructor(ctx: any);
|
|
13
|
+
requestAdjust(adjust: number, onAdjusted: (diff: number) => void): void;
|
|
14
|
+
getAppliedAdjust(): number;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
type LegendListPropsBase<ItemT, TScrollView extends ComponentProps<typeof ScrollView> | ComponentProps<typeof Animated.ScrollView>> = Omit<TScrollView, 'contentOffset' | 'contentInset' | 'maintainVisibleContentPosition' | 'stickyHeaderIndices'> & {
|
|
5
18
|
data: ArrayLike<any> & ItemT[];
|
|
6
19
|
initialScrollOffset?: number;
|
|
7
20
|
initialScrollIndex?: number;
|
|
@@ -15,6 +28,7 @@ type LegendListProps<ItemT> = Omit<ComponentProps<typeof ScrollView>, 'contentOf
|
|
|
15
28
|
alignItemsAtEnd?: boolean;
|
|
16
29
|
maintainVisibleContentPosition?: boolean;
|
|
17
30
|
numColumns?: number;
|
|
31
|
+
refScrollView?: React.Ref<ScrollView>;
|
|
18
32
|
estimatedItemSize?: number;
|
|
19
33
|
getEstimatedItemSize?: (index: number, item: ItemT) => number;
|
|
20
34
|
onStartReached?: ((info: {
|
|
@@ -36,14 +50,20 @@ type LegendListProps<ItemT> = Omit<ComponentProps<typeof ScrollView>, 'contentOf
|
|
|
36
50
|
viewabilityConfig?: ViewabilityConfig;
|
|
37
51
|
onViewableItemsChanged?: OnViewableItemsChanged | undefined;
|
|
38
52
|
};
|
|
53
|
+
type LegendListProps<ItemT> = LegendListPropsBase<ItemT, ComponentProps<typeof ScrollView>>;
|
|
39
54
|
interface InternalState {
|
|
55
|
+
anchorElement?: {
|
|
56
|
+
id: string;
|
|
57
|
+
coordinate: number;
|
|
58
|
+
};
|
|
59
|
+
belowAnchorElementPositions?: Map<string, number>;
|
|
60
|
+
rowHeights: Map<number, number>;
|
|
40
61
|
positions: Map<string, number>;
|
|
41
62
|
columns: Map<string, number>;
|
|
42
63
|
sizes: Map<string, number>;
|
|
43
64
|
sizesLaidOut: Map<string, number> | undefined;
|
|
44
65
|
pendingAdjust: number;
|
|
45
66
|
animFrameLayout: any;
|
|
46
|
-
animFrameTotalSize: number | null;
|
|
47
67
|
isStartReached: boolean;
|
|
48
68
|
isEndReached: boolean;
|
|
49
69
|
isAtBottom: boolean;
|
|
@@ -53,6 +73,7 @@ interface InternalState {
|
|
|
53
73
|
hasScrolled: boolean;
|
|
54
74
|
scrollLength: number;
|
|
55
75
|
startBuffered: number;
|
|
76
|
+
startBufferedId?: string;
|
|
56
77
|
startNoBuffer: number;
|
|
57
78
|
endBuffered: number;
|
|
58
79
|
endNoBuffer: number;
|
|
@@ -61,8 +82,9 @@ interface InternalState {
|
|
|
61
82
|
scrollPrev: number;
|
|
62
83
|
scrollPrevTime: number;
|
|
63
84
|
scrollVelocity: number;
|
|
64
|
-
|
|
85
|
+
scrollAdjustHandler: ScrollAdjustHandler;
|
|
65
86
|
totalSize: number;
|
|
87
|
+
totalSizeBelowAnchor: number;
|
|
66
88
|
timeouts: Set<number>;
|
|
67
89
|
timeoutSizeMessage: any;
|
|
68
90
|
nativeMarginTop: number;
|
|
@@ -78,6 +100,7 @@ interface InternalState {
|
|
|
78
100
|
time: number;
|
|
79
101
|
}>;
|
|
80
102
|
scrollTimer: Timer | undefined;
|
|
103
|
+
startReachedBlockedByTimer: boolean;
|
|
81
104
|
}
|
|
82
105
|
interface ViewableRange<T> {
|
|
83
106
|
startBuffered: number;
|
|
@@ -194,4 +217,4 @@ declare const LegendList: <T>(props: LegendListProps<T> & {
|
|
|
194
217
|
ref?: ForwardedRef<LegendListRef>;
|
|
195
218
|
}) => ReactElement;
|
|
196
219
|
|
|
197
|
-
export { type InternalState, LegendList, type LegendListProps, type LegendListRecyclingState, type LegendListRef, type LegendListRenderItemProps, type OnViewableItemsChanged, type ViewAmountToken, type ViewToken, type ViewabilityAmountCallback, type ViewabilityCallback, type ViewabilityConfig, type ViewabilityConfigCallbackPair, type ViewabilityConfigCallbackPairs, type ViewableRange };
|
|
220
|
+
export { type InternalState, LegendList, type LegendListProps, type LegendListPropsBase, type LegendListRecyclingState, type LegendListRef, type LegendListRenderItemProps, type OnViewableItemsChanged, type ViewAmountToken, type ViewToken, type ViewabilityAmountCallback, type ViewabilityCallback, type ViewabilityConfig, type ViewabilityConfigCallbackPair, type ViewabilityConfigCallbackPairs, type ViewableRange };
|
package/index.d.ts
CHANGED
|
@@ -1,7 +1,20 @@
|
|
|
1
1
|
import { ComponentProps, ReactNode, ForwardedRef, ReactElement } from 'react';
|
|
2
2
|
import { ScrollView, StyleProp, ViewStyle, ScrollViewComponent, ScrollResponderMixin } from 'react-native';
|
|
3
|
+
import Animated from 'react-native-reanimated';
|
|
3
4
|
|
|
4
|
-
|
|
5
|
+
declare class ScrollAdjustHandler {
|
|
6
|
+
private ctx;
|
|
7
|
+
private appliedAdjust;
|
|
8
|
+
private pendingAdjust;
|
|
9
|
+
private busy;
|
|
10
|
+
private context;
|
|
11
|
+
private firstAdjust;
|
|
12
|
+
constructor(ctx: any);
|
|
13
|
+
requestAdjust(adjust: number, onAdjusted: (diff: number) => void): void;
|
|
14
|
+
getAppliedAdjust(): number;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
type LegendListPropsBase<ItemT, TScrollView extends ComponentProps<typeof ScrollView> | ComponentProps<typeof Animated.ScrollView>> = Omit<TScrollView, 'contentOffset' | 'contentInset' | 'maintainVisibleContentPosition' | 'stickyHeaderIndices'> & {
|
|
5
18
|
data: ArrayLike<any> & ItemT[];
|
|
6
19
|
initialScrollOffset?: number;
|
|
7
20
|
initialScrollIndex?: number;
|
|
@@ -15,6 +28,7 @@ type LegendListProps<ItemT> = Omit<ComponentProps<typeof ScrollView>, 'contentOf
|
|
|
15
28
|
alignItemsAtEnd?: boolean;
|
|
16
29
|
maintainVisibleContentPosition?: boolean;
|
|
17
30
|
numColumns?: number;
|
|
31
|
+
refScrollView?: React.Ref<ScrollView>;
|
|
18
32
|
estimatedItemSize?: number;
|
|
19
33
|
getEstimatedItemSize?: (index: number, item: ItemT) => number;
|
|
20
34
|
onStartReached?: ((info: {
|
|
@@ -36,14 +50,20 @@ type LegendListProps<ItemT> = Omit<ComponentProps<typeof ScrollView>, 'contentOf
|
|
|
36
50
|
viewabilityConfig?: ViewabilityConfig;
|
|
37
51
|
onViewableItemsChanged?: OnViewableItemsChanged | undefined;
|
|
38
52
|
};
|
|
53
|
+
type LegendListProps<ItemT> = LegendListPropsBase<ItemT, ComponentProps<typeof ScrollView>>;
|
|
39
54
|
interface InternalState {
|
|
55
|
+
anchorElement?: {
|
|
56
|
+
id: string;
|
|
57
|
+
coordinate: number;
|
|
58
|
+
};
|
|
59
|
+
belowAnchorElementPositions?: Map<string, number>;
|
|
60
|
+
rowHeights: Map<number, number>;
|
|
40
61
|
positions: Map<string, number>;
|
|
41
62
|
columns: Map<string, number>;
|
|
42
63
|
sizes: Map<string, number>;
|
|
43
64
|
sizesLaidOut: Map<string, number> | undefined;
|
|
44
65
|
pendingAdjust: number;
|
|
45
66
|
animFrameLayout: any;
|
|
46
|
-
animFrameTotalSize: number | null;
|
|
47
67
|
isStartReached: boolean;
|
|
48
68
|
isEndReached: boolean;
|
|
49
69
|
isAtBottom: boolean;
|
|
@@ -53,6 +73,7 @@ interface InternalState {
|
|
|
53
73
|
hasScrolled: boolean;
|
|
54
74
|
scrollLength: number;
|
|
55
75
|
startBuffered: number;
|
|
76
|
+
startBufferedId?: string;
|
|
56
77
|
startNoBuffer: number;
|
|
57
78
|
endBuffered: number;
|
|
58
79
|
endNoBuffer: number;
|
|
@@ -61,8 +82,9 @@ interface InternalState {
|
|
|
61
82
|
scrollPrev: number;
|
|
62
83
|
scrollPrevTime: number;
|
|
63
84
|
scrollVelocity: number;
|
|
64
|
-
|
|
85
|
+
scrollAdjustHandler: ScrollAdjustHandler;
|
|
65
86
|
totalSize: number;
|
|
87
|
+
totalSizeBelowAnchor: number;
|
|
66
88
|
timeouts: Set<number>;
|
|
67
89
|
timeoutSizeMessage: any;
|
|
68
90
|
nativeMarginTop: number;
|
|
@@ -78,6 +100,7 @@ interface InternalState {
|
|
|
78
100
|
time: number;
|
|
79
101
|
}>;
|
|
80
102
|
scrollTimer: Timer | undefined;
|
|
103
|
+
startReachedBlockedByTimer: boolean;
|
|
81
104
|
}
|
|
82
105
|
interface ViewableRange<T> {
|
|
83
106
|
startBuffered: number;
|
|
@@ -194,4 +217,4 @@ declare const LegendList: <T>(props: LegendListProps<T> & {
|
|
|
194
217
|
ref?: ForwardedRef<LegendListRef>;
|
|
195
218
|
}) => ReactElement;
|
|
196
219
|
|
|
197
|
-
export { type InternalState, LegendList, type LegendListProps, type LegendListRecyclingState, type LegendListRef, type LegendListRenderItemProps, type OnViewableItemsChanged, type ViewAmountToken, type ViewToken, type ViewabilityAmountCallback, type ViewabilityCallback, type ViewabilityConfig, type ViewabilityConfigCallbackPair, type ViewabilityConfigCallbackPairs, type ViewableRange };
|
|
220
|
+
export { type InternalState, LegendList, type LegendListProps, type LegendListPropsBase, type LegendListRecyclingState, type LegendListRef, type LegendListRenderItemProps, type OnViewableItemsChanged, type ViewAmountToken, type ViewToken, type ViewabilityAmountCallback, type ViewabilityCallback, type ViewabilityConfig, type ViewabilityConfigCallbackPair, type ViewabilityConfigCallbackPairs, type ViewableRange };
|