@legendapp/list 3.4.0 → 3.6.0
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 +10 -0
- package/README.md +33 -0
- package/animated.d.ts +6 -0
- package/keyboard-legacy.d.ts +4 -0
- package/keyboard.d.ts +4 -0
- package/package.json +1 -1
- package/react-native.d.ts +8 -0
- package/react-native.js +145 -66
- package/react-native.mjs +145 -66
- package/react-native.web.d.ts +20 -2
- package/react-native.web.js +320 -193
- package/react-native.web.mjs +320 -193
- package/react.d.ts +20 -2
- package/react.js +320 -193
- package/react.mjs +320 -193
- package/reanimated.d.ts +6 -0
- package/section-list.d.ts +10 -1
- package/section-list.js +10 -2
- package/section-list.mjs +10 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
## 3.6.0
|
|
2
|
+
|
|
3
|
+
- Feat: Add `viewPositionFallback` to align oversized items to the start or end of the viewport during initial or programmatic scrolling, while keeping `viewPosition` alignment for items that fit.
|
|
4
|
+
|
|
5
|
+
## 3.5.0
|
|
6
|
+
|
|
7
|
+
- Feat: Add `scrollElement` so web lists can share an ancestor element's scrollbar
|
|
8
|
+
- Fix: Stopping scrolling keeps rows prepared in the last scroll direction instead of shifting the render buffer backward.
|
|
9
|
+
- Perf: Single-column lists do less layout work during initial rendering and scrolling when item sizes and data are unchanged.
|
|
10
|
+
|
|
1
11
|
## 3.4.0
|
|
2
12
|
|
|
3
13
|
- Feat: Add `onReady`, called after each initial placement and scroll cycle completes, including cycles restarted by a `dataKey` change.
|
package/README.md
CHANGED
|
@@ -112,6 +112,39 @@ export default LegendListExample
|
|
|
112
112
|
|
|
113
113
|
---
|
|
114
114
|
|
|
115
|
+
### Sharing a scrollbar on the web
|
|
116
|
+
|
|
117
|
+
React DOM lists can use an ancestor element's scrollbar with `scrollElement`:
|
|
118
|
+
|
|
119
|
+
```tsx
|
|
120
|
+
import { LegendList } from "@legendapp/list/react";
|
|
121
|
+
import { useState } from "react";
|
|
122
|
+
|
|
123
|
+
function History({ swaps, renderSwap }) {
|
|
124
|
+
const [scrollElement, setScrollElement] = useState<HTMLDivElement | null>(null);
|
|
125
|
+
|
|
126
|
+
return (
|
|
127
|
+
<div ref={setScrollElement} style={{ height: 600, overflow: "auto" }}>
|
|
128
|
+
<ProfileHeader />
|
|
129
|
+
<LegendList
|
|
130
|
+
data={swaps}
|
|
131
|
+
renderItem={renderSwap}
|
|
132
|
+
keyExtractor={(swap) => swap.id}
|
|
133
|
+
scrollElement={scrollElement}
|
|
134
|
+
/>
|
|
135
|
+
</div>
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
Use a state-backed callback ref so the list receives the element after mounting and whenever it changes. `null` waits for an external element; `undefined` keeps the default list-owned scrollbar. The element must be an ancestor of the list. Keep the list's own height unconstrained so its content contributes to the parent's scroll range.
|
|
141
|
+
|
|
142
|
+
Multiple lists can share the same element, including lists in separate columns. Each uses the owner's viewport on the scroll axis and its own width/height on the cross axis. Content above the list is accounted for automatically, including preceding content that resizes. `scrollToIndex`, `scrollToOffset`, and `scrollToEnd` remain list-relative and move the shared owner.
|
|
143
|
+
|
|
144
|
+
`maintainVisibleContentPosition` anchors changes to the list's own rows; it does not freeze the layout of surrounding content. An offscreen list does not pull the owner back into view to apply a measurement correction.
|
|
145
|
+
|
|
146
|
+
`useWindowScroll` continues to use the browser window. Both modes share the same web implementation; `scrollElement` takes precedence when provided. As with window scrolling, external mode does not configure the owner's scrollbar styling or CSS snapping. It is not supported with `renderScrollComponent`.
|
|
147
|
+
|
|
115
148
|
## How to Build
|
|
116
149
|
|
|
117
150
|
1. `bun i`
|
package/animated.d.ts
CHANGED
|
@@ -225,6 +225,8 @@ interface LegendListSpecificProps<ItemT, TItemType extends string | undefined> {
|
|
|
225
225
|
index: number;
|
|
226
226
|
viewOffset?: number | undefined;
|
|
227
227
|
viewPosition?: number | undefined;
|
|
228
|
+
/** Alignment used only when the item exceeds the viewport. Omit to preserve viewPosition. */
|
|
229
|
+
viewPositionFallback?: "start" | "end";
|
|
228
230
|
};
|
|
229
231
|
/**
|
|
230
232
|
* Initial scroll position in pixels.
|
|
@@ -651,6 +653,8 @@ type LegendListRef$1 = {
|
|
|
651
653
|
index: number;
|
|
652
654
|
viewOffset?: number | undefined;
|
|
653
655
|
viewPosition?: number | undefined;
|
|
656
|
+
/** Alignment used only when the item exceeds the viewport. Omit to preserve viewPosition. */
|
|
657
|
+
viewPositionFallback?: "start" | "end";
|
|
654
658
|
}): Promise<void>;
|
|
655
659
|
/**
|
|
656
660
|
* Scrolls to a specific item in the list.
|
|
@@ -665,6 +669,8 @@ type LegendListRef$1 = {
|
|
|
665
669
|
item: any;
|
|
666
670
|
viewOffset?: number | undefined;
|
|
667
671
|
viewPosition?: number | undefined;
|
|
672
|
+
/** Alignment used only when the item exceeds the viewport. Omit to preserve viewPosition. */
|
|
673
|
+
viewPositionFallback?: "start" | "end";
|
|
668
674
|
}): Promise<void>;
|
|
669
675
|
/**
|
|
670
676
|
* Scrolls to a specific offset in pixels.
|
package/keyboard-legacy.d.ts
CHANGED
|
@@ -190,6 +190,8 @@ type LegendListRef$1 = {
|
|
|
190
190
|
index: number;
|
|
191
191
|
viewOffset?: number | undefined;
|
|
192
192
|
viewPosition?: number | undefined;
|
|
193
|
+
/** Alignment used only when the item exceeds the viewport. Omit to preserve viewPosition. */
|
|
194
|
+
viewPositionFallback?: "start" | "end";
|
|
193
195
|
}): Promise<void>;
|
|
194
196
|
/**
|
|
195
197
|
* Scrolls to a specific item in the list.
|
|
@@ -204,6 +206,8 @@ type LegendListRef$1 = {
|
|
|
204
206
|
item: any;
|
|
205
207
|
viewOffset?: number | undefined;
|
|
206
208
|
viewPosition?: number | undefined;
|
|
209
|
+
/** Alignment used only when the item exceeds the viewport. Omit to preserve viewPosition. */
|
|
210
|
+
viewPositionFallback?: "start" | "end";
|
|
207
211
|
}): Promise<void>;
|
|
208
212
|
/**
|
|
209
213
|
* Scrolls to a specific offset in pixels.
|
package/keyboard.d.ts
CHANGED
|
@@ -208,6 +208,8 @@ type LegendListRef$1 = {
|
|
|
208
208
|
index: number;
|
|
209
209
|
viewOffset?: number | undefined;
|
|
210
210
|
viewPosition?: number | undefined;
|
|
211
|
+
/** Alignment used only when the item exceeds the viewport. Omit to preserve viewPosition. */
|
|
212
|
+
viewPositionFallback?: "start" | "end";
|
|
211
213
|
}): Promise<void>;
|
|
212
214
|
/**
|
|
213
215
|
* Scrolls to a specific item in the list.
|
|
@@ -222,6 +224,8 @@ type LegendListRef$1 = {
|
|
|
222
224
|
item: any;
|
|
223
225
|
viewOffset?: number | undefined;
|
|
224
226
|
viewPosition?: number | undefined;
|
|
227
|
+
/** Alignment used only when the item exceeds the viewport. Omit to preserve viewPosition. */
|
|
228
|
+
viewPositionFallback?: "start" | "end";
|
|
225
229
|
}): Promise<void>;
|
|
226
230
|
/**
|
|
227
231
|
* Scrolls to a specific offset in pixels.
|
package/package.json
CHANGED
package/react-native.d.ts
CHANGED
|
@@ -225,6 +225,8 @@ interface LegendListSpecificProps<ItemT, TItemType extends string | undefined> {
|
|
|
225
225
|
index: number;
|
|
226
226
|
viewOffset?: number | undefined;
|
|
227
227
|
viewPosition?: number | undefined;
|
|
228
|
+
/** Alignment used only when the item exceeds the viewport. Omit to preserve viewPosition. */
|
|
229
|
+
viewPositionFallback?: "start" | "end";
|
|
228
230
|
};
|
|
229
231
|
/**
|
|
230
232
|
* Initial scroll position in pixels.
|
|
@@ -651,6 +653,8 @@ type LegendListRef$1 = {
|
|
|
651
653
|
index: number;
|
|
652
654
|
viewOffset?: number | undefined;
|
|
653
655
|
viewPosition?: number | undefined;
|
|
656
|
+
/** Alignment used only when the item exceeds the viewport. Omit to preserve viewPosition. */
|
|
657
|
+
viewPositionFallback?: "start" | "end";
|
|
654
658
|
}): Promise<void>;
|
|
655
659
|
/**
|
|
656
660
|
* Scrolls to a specific item in the list.
|
|
@@ -665,6 +669,8 @@ type LegendListRef$1 = {
|
|
|
665
669
|
item: any;
|
|
666
670
|
viewOffset?: number | undefined;
|
|
667
671
|
viewPosition?: number | undefined;
|
|
672
|
+
/** Alignment used only when the item exceeds the viewport. Omit to preserve viewPosition. */
|
|
673
|
+
viewPositionFallback?: "start" | "end";
|
|
668
674
|
}): Promise<void>;
|
|
669
675
|
/**
|
|
670
676
|
* Scrolls to a specific offset in pixels.
|
|
@@ -763,6 +769,8 @@ interface ScrollIndexWithOffset {
|
|
|
763
769
|
index: number;
|
|
764
770
|
viewOffset?: number;
|
|
765
771
|
viewPosition?: number;
|
|
772
|
+
/** Alignment used only when the item exceeds the viewport. Omit to preserve viewPosition. */
|
|
773
|
+
viewPositionFallback?: "start" | "end";
|
|
766
774
|
}
|
|
767
775
|
interface ScrollIndexWithOffsetPosition extends ScrollIndexWithOffset {
|
|
768
776
|
viewPosition?: number;
|