1+ diff --git a/animated.d.ts b/animated.d.ts
2+ index c519061902a1fc47c7722a1ed2e6d9c3e971bfaa..f4f94bd09203ec6dc6bc9b2e6fd789ee72469b97 100644
3+ --- a/animated.d.ts
4+ +++ b/animated.d.ts
5+ @@ -282,6 +282,13 @@ interface LegendListSpecificProps<ItemT, TItemType extends string | undefined> {
6+ * @default false
7+ */
8+ maintainScrollAtEnd?: boolean | MaintainScrollAtEndOptions;
9+ + /**
10+ + * T3 patch: called when a size change held the end and moved the top visible row on screen by
11+ + * `shift` points (down is positive). Native only.
12+ + */
13+ + onEndHoldShift?: (shift: number) => void;
14+ + /** T3 patch: a change marks a reflow, such as a new width, for `onEndHoldShift`. */
15+ + sizeChangeKey?: string | number;
16+ /**
17+ * Distance threshold in percentage of screen size to trigger maintainScrollAtEnd.
18+ * @default 0.1
19+ diff --git a/react-native.d.ts b/react-native.d.ts
20+ index 983e937cf5c19134e949e0b2f609ba21541b77af..124bdd5243678a4d65f024841261861dd96d83f2 100644
21+ --- a/react-native.d.ts
22+ +++ b/react-native.d.ts
23+ @@ -282,6 +282,13 @@ interface LegendListSpecificProps<ItemT, TItemType extends string | undefined> {
24+ * @default false
25+ */
26+ maintainScrollAtEnd?: boolean | MaintainScrollAtEndOptions;
27+ + /**
28+ + * T3 patch: called when a size change held the end and moved the top visible row on screen by
29+ + * `shift` points (down is positive). Native only.
30+ + */
31+ + onEndHoldShift?: (shift: number) => void;
32+ + /** T3 patch: a change marks a reflow, such as a new width, for `onEndHoldShift`. */
33+ + sizeChangeKey?: string | number;
34+ /**
35+ * Distance threshold in percentage of screen size to trigger maintainScrollAtEnd.
36+ * @default 0.1
137diff --git a/react-native.js b/react-native.js
2- index 4af685dfb961eb0c8a4bf1ae9132c9304cf4fa4d..df4ead7ae4f03cd0fbcd99a3df7d95e15b1852b1 100644
38+ index 4af685dfb961eb0c8a4bf1ae9132c9304cf4fa4d..901dd035eafc3846e390dc006215a2977933ae5c 100644
339--- a/react-native.js
440+++ b/react-native.js
5- @@ -1795,7 +1795,35 @@ function resolvePendingNativeMVCPAdjust(ctx, newScroll) {
41+ @@ -1795,7 +1795,51 @@ function resolvePendingNativeMVCPAdjust(ctx, newScroll) {
642 }
743 return false;
844 }
@@ -18,11 +54,16 @@ index 4af685dfb961eb0c8a4bf1ae9132c9304cf4fa4d..df4ead7ae4f03cd0fbcd99a3df7d95e1
1854+ if (!shouldHoldEndOnSizeChange(ctx, dataChanged)) {
1955+ return restore;
2056+ }
57+ + const { idsInView, indexByKey, positions } = ctx.state;
58+ + const anchorId = idsInView.find((id) => indexByKey.get(id) !== void 0);
59+ + const anchorIndex = anchorId === void 0 ? void 0 : indexByKey.get(anchorId);
60+ + const anchorPosition = anchorIndex === void 0 ? void 0 : positions[anchorIndex];
2161+ return () => {
2262+ if (!shouldHoldEndOnSizeChange(ctx, dataChanged)) {
2363+ restore == null ? void 0 : restore();
2464+ return;
2565+ }
66+ + const scrollBefore = ctx.state.scroll;
2667+ // Content that shrinks under an offset past its new end pulls the native offset back by itself.
2768+ const endOffset = getScrollRangeEnd(ctx);
2869+ if (ctx.state.scroll > endOffset) {
@@ -32,17 +73,50 @@ index 4af685dfb961eb0c8a4bf1ae9132c9304cf4fa4d..df4ead7ae4f03cd0fbcd99a3df7d95e1
3273+ if (Math.abs(positionDiff) > MVCP_POSITION_EPSILON) {
3374+ requestAdjust(ctx, positionDiff, adjustmentSource);
3475+ }
76+ + // T3 patch: how far holding the end moved the top visible row on screen, for a caller that
77+ + // eases the jump. Reported only shortly after `sizeChangeKey` changes, so growth at the end
78+ + // while streaming still follows at once.
79+ + const onEndHoldShift = ctx.state.props.onEndHoldShift;
80+ + const newAnchorIndex = anchorId === void 0 ? void 0 : ctx.state.indexByKey.get(anchorId);
81+ + const newAnchorPosition = newAnchorIndex === void 0 ? void 0 : ctx.state.positions[newAnchorIndex];
82+ + const inReflow = ctx.state.endHoldReflowUntil !== void 0 && Date.now() < ctx.state.endHoldReflowUntil;
83+ + if (onEndHoldShift && inReflow && anchorPosition !== void 0 && newAnchorPosition !== void 0) {
84+ + const shift = newAnchorPosition - anchorPosition - (ctx.state.scroll - scrollBefore);
85+ + if (Math.abs(shift) > MVCP_POSITION_EPSILON) onEndHoldShift(shift);
86+ + }
3587+ };
3688+ }
3789+ function prepareDefaultMVCP(ctx, dataChanged, adjustmentSource) {
3890 var _a3, _b, _c;
3991 const state = ctx.state;
4092 const { idsInView, positions, props } = state;
93+ @@ -8366,6 +8410,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
94+ ListHeaderComponent,
95+ maintainScrollAtEnd = false,
96+ maintainScrollAtEndThreshold = 0.1,
97+ + onEndHoldShift,
98+ + sizeChangeKey,
99+ maintainVisibleContentPosition: maintainVisibleContentPositionProp,
100+ numColumns: numColumnsProp = 1,
101+ overrideItemLayout,
102+ @@ -8625,7 +8671,12 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
103+ const throttledOnScroll = useThrottledOnScroll(onScrollProp != null ? onScrollProp : noopOnScroll, scrollEventThrottle != null ? scrollEventThrottle : 0);
104+ const throttleScrollFn = scrollEventThrottle && onScrollProp ? throttledOnScroll : onScrollProp;
105+ const didAnchoredEndSpaceAnchorIndexChange = !isFirstLocal && !didDataChangeLocal && ((_r = state.props.anchoredEndSpace) == null ? void 0 : _r.anchorIndex) !== (anchoredEndSpace == null ? void 0 : anchoredEndSpace.anchorIndex);
106+ + if (state.props.sizeChangeKey !== void 0 && sizeChangeKey !== state.props.sizeChangeKey) {
107+ + state.endHoldReflowUntil = Date.now() + 500;
108+ + }
109+ state.props = {
110+ + onEndHoldShift,
111+ + sizeChangeKey,
112+ adaptiveRender: experimental_adaptiveRender,
113+ alignItemsAtEnd,
114+ alignItemsAtEndPaddingEnabled: useAlignItemsAtEndPadding,
41115diff --git a/react-native.mjs b/react-native.mjs
42- index 9ebfddc183a9b202d35c990a387c9b628feeb185..c414a49e866ecab1393645101fb67d55530a7d00 100644
116+ index 9ebfddc183a9b202d35c990a387c9b628feeb185..cf3433ee2f84c8d923bf1200bb1ff1b640f557d4 100644
43117--- a/react-native.mjs
44118+++ b/react-native.mjs
45- @@ -1774,7 +1774,35 @@ function resolvePendingNativeMVCPAdjust(ctx, newScroll) {
119+ @@ -1774,7 +1774,51 @@ function resolvePendingNativeMVCPAdjust(ctx, newScroll) {
46120 }
47121 return false;
48122 }
@@ -58,11 +132,16 @@ index 9ebfddc183a9b202d35c990a387c9b628feeb185..c414a49e866ecab1393645101fb67d55
58132+ if (!shouldHoldEndOnSizeChange(ctx, dataChanged)) {
59133+ return restore;
60134+ }
135+ + const { idsInView, indexByKey, positions } = ctx.state;
136+ + const anchorId = idsInView.find((id) => indexByKey.get(id) !== void 0);
137+ + const anchorIndex = anchorId === void 0 ? void 0 : indexByKey.get(anchorId);
138+ + const anchorPosition = anchorIndex === void 0 ? void 0 : positions[anchorIndex];
61139+ return () => {
62140+ if (!shouldHoldEndOnSizeChange(ctx, dataChanged)) {
63141+ restore == null ? void 0 : restore();
64142+ return;
65143+ }
144+ + const scrollBefore = ctx.state.scroll;
66145+ // Content that shrinks under an offset past its new end pulls the native offset back by itself.
67146+ const endOffset = getScrollRangeEnd(ctx);
68147+ if (ctx.state.scroll > endOffset) {
@@ -72,9 +151,114 @@ index 9ebfddc183a9b202d35c990a387c9b628feeb185..c414a49e866ecab1393645101fb67d55
72151+ if (Math.abs(positionDiff) > MVCP_POSITION_EPSILON) {
73152+ requestAdjust(ctx, positionDiff, adjustmentSource);
74153+ }
154+ + // T3 patch: how far holding the end moved the top visible row on screen, for a caller that
155+ + // eases the jump. Reported only shortly after `sizeChangeKey` changes, so growth at the end
156+ + // while streaming still follows at once.
157+ + const onEndHoldShift = ctx.state.props.onEndHoldShift;
158+ + const newAnchorIndex = anchorId === void 0 ? void 0 : ctx.state.indexByKey.get(anchorId);
159+ + const newAnchorPosition = newAnchorIndex === void 0 ? void 0 : ctx.state.positions[newAnchorIndex];
160+ + const inReflow = ctx.state.endHoldReflowUntil !== void 0 && Date.now() < ctx.state.endHoldReflowUntil;
161+ + if (onEndHoldShift && inReflow && anchorPosition !== void 0 && newAnchorPosition !== void 0) {
162+ + const shift = newAnchorPosition - anchorPosition - (ctx.state.scroll - scrollBefore);
163+ + if (Math.abs(shift) > MVCP_POSITION_EPSILON) onEndHoldShift(shift);
164+ + }
75165+ };
76166+ }
77167+ function prepareDefaultMVCP(ctx, dataChanged, adjustmentSource) {
78168 var _a3, _b, _c;
79169 const state = ctx.state;
80170 const { idsInView, positions, props } = state;
171+ @@ -8345,6 +8389,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
172+ ListHeaderComponent,
173+ maintainScrollAtEnd = false,
174+ maintainScrollAtEndThreshold = 0.1,
175+ + onEndHoldShift,
176+ + sizeChangeKey,
177+ maintainVisibleContentPosition: maintainVisibleContentPositionProp,
178+ numColumns: numColumnsProp = 1,
179+ overrideItemLayout,
180+ @@ -8604,7 +8650,12 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
181+ const throttledOnScroll = useThrottledOnScroll(onScrollProp != null ? onScrollProp : noopOnScroll, scrollEventThrottle != null ? scrollEventThrottle : 0);
182+ const throttleScrollFn = scrollEventThrottle && onScrollProp ? throttledOnScroll : onScrollProp;
183+ const didAnchoredEndSpaceAnchorIndexChange = !isFirstLocal && !didDataChangeLocal && ((_r = state.props.anchoredEndSpace) == null ? void 0 : _r.anchorIndex) !== (anchoredEndSpace == null ? void 0 : anchoredEndSpace.anchorIndex);
184+ + if (state.props.sizeChangeKey !== void 0 && sizeChangeKey !== state.props.sizeChangeKey) {
185+ + state.endHoldReflowUntil = Date.now() + 500;
186+ + }
187+ state.props = {
188+ + onEndHoldShift,
189+ + sizeChangeKey,
190+ adaptiveRender: experimental_adaptiveRender,
191+ alignItemsAtEnd,
192+ alignItemsAtEndPaddingEnabled: useAlignItemsAtEndPadding,
193+ diff --git a/react-native.web.d.ts b/react-native.web.d.ts
194+ index 358fcd7faa598af8a4382719b7e7198b3ce04588..d36440a103ddee67b15e9c287781ce7720560900 100644
195+ --- a/react-native.web.d.ts
196+ +++ b/react-native.web.d.ts
197+ @@ -309,6 +309,13 @@ interface LegendListSpecificProps<ItemT, TItemType extends string | undefined> {
198+ * @default false
199+ */
200+ maintainScrollAtEnd?: boolean | MaintainScrollAtEndOptions;
201+ + /**
202+ + * T3 patch: called when a size change held the end and moved the top visible row on screen by
203+ + * `shift` points (down is positive). Native only.
204+ + */
205+ + onEndHoldShift?: (shift: number) => void;
206+ + /** T3 patch: a change marks a reflow, such as a new width, for `onEndHoldShift`. */
207+ + sizeChangeKey?: string | number;
208+ /**
209+ * Distance threshold in percentage of screen size to trigger maintainScrollAtEnd.
210+ * @default 0.1
211+ diff --git a/react.d.ts b/react.d.ts
212+ index 358fcd7faa598af8a4382719b7e7198b3ce04588..d36440a103ddee67b15e9c287781ce7720560900 100644
213+ --- a/react.d.ts
214+ +++ b/react.d.ts
215+ @@ -309,6 +309,13 @@ interface LegendListSpecificProps<ItemT, TItemType extends string | undefined> {
216+ * @default false
217+ */
218+ maintainScrollAtEnd?: boolean | MaintainScrollAtEndOptions;
219+ + /**
220+ + * T3 patch: called when a size change held the end and moved the top visible row on screen by
221+ + * `shift` points (down is positive). Native only.
222+ + */
223+ + onEndHoldShift?: (shift: number) => void;
224+ + /** T3 patch: a change marks a reflow, such as a new width, for `onEndHoldShift`. */
225+ + sizeChangeKey?: string | number;
226+ /**
227+ * Distance threshold in percentage of screen size to trigger maintainScrollAtEnd.
228+ * @default 0.1
229+ diff --git a/reanimated.d.ts b/reanimated.d.ts
230+ index 5b568f2d39783dd257e97e4727c45373cac41165..bc74fb4d3359deddc3b8bca929337734162c55f9 100644
231+ --- a/reanimated.d.ts
232+ +++ b/reanimated.d.ts
233+ @@ -283,6 +283,13 @@ interface LegendListSpecificProps<ItemT, TItemType extends string | undefined> {
234+ * @default false
235+ */
236+ maintainScrollAtEnd?: boolean | MaintainScrollAtEndOptions;
237+ + /**
238+ + * T3 patch: called when a size change held the end and moved the top visible row on screen by
239+ + * `shift` points (down is positive). Native only.
240+ + */
241+ + onEndHoldShift?: (shift: number) => void;
242+ + /** T3 patch: a change marks a reflow, such as a new width, for `onEndHoldShift`. */
243+ + sizeChangeKey?: string | number;
244+ /**
245+ * Distance threshold in percentage of screen size to trigger maintainScrollAtEnd.
246+ * @default 0.1
247+ diff --git a/section-list.d.ts b/section-list.d.ts
248+ index 94edf333f0d0a140534421f3c72886eb8a48c130..8d96b82054163d73d2ed763c36a6baa2eb0880b0 100644
249+ --- a/section-list.d.ts
250+ +++ b/section-list.d.ts
251+ @@ -339,6 +339,13 @@ interface LegendListSpecificProps<ItemT, TItemType extends string | undefined> {
252+ * @default false
253+ */
254+ maintainScrollAtEnd?: boolean | MaintainScrollAtEndOptions;
255+ + /**
256+ + * T3 patch: called when a size change held the end and moved the top visible row on screen by
257+ + * `shift` points (down is positive). Native only.
258+ + */
259+ + onEndHoldShift?: (shift: number) => void;
260+ + /** T3 patch: a change marks a reflow, such as a new width, for `onEndHoldShift`. */
261+ + sizeChangeKey?: string | number;
262+ /**
263+ * Distance threshold in percentage of screen size to trigger maintainScrollAtEnd.
264+ * @default 0.1
0 commit comments