Open History to see the last commit
1diff --git a/keyboard.d.ts b/keyboard.d.ts
2index 367945cdfa8a8c260b7a127657a75c016c9ab46f..95263268a47d3f1f57bbc5d528bcc77674f9121f 100644
3--- a/keyboard.d.ts
4+++ b/keyboard.d.ts
5@@ -279,7 +279,7 @@ type KeyboardChatComposerInsetListRef = {
6 type KeyboardChatComposerRef = {
7 current: Pick<View, "measure"> | null;
8 };
9-declare function useKeyboardChatComposerInset(listRef: KeyboardChatComposerInsetListRef, composerRef: KeyboardChatComposerRef, initialHeight?: number): {
10+declare function useKeyboardChatComposerInset(listRef: KeyboardChatComposerInsetListRef, composerRef: KeyboardChatComposerRef, initialHeight?: number, heightAdjustment?: number): {
11 contentInsetEndAdjustment: SharedValue<number>;
12 onComposerLayout: (event: LayoutChangeEvent) => void;
13 };
14@@ -288,8 +288,10 @@ declare function useKeyboardScrollToEnd({ freeze: freezeProp, listRef }: UseKeyb
15 scrollMessageToEnd: ({ animated, closeKeyboard }: ScrollMessageToEndOptions) => Promise<void>;
16 };
17 declare const KeyboardAwareLegendList: <ItemT>(props: Omit<AnimatedLegendListProps<ItemT>, "anchoredEndSpace" | "contentInsetEndAdjustment" | "renderScrollComponent"> & KeyboardChatScrollViewPropsUnique & {
18+ adjustedInsetCompensation?: number;
19 anchoredEndSpace?: AnchoredEndSpaceConfig;
20 contentInsetEndAdjustment?: SharedValue<number>;
21+ contentInsetEndStaticAdjustment?: number;
22 keyboardOffset?: number;
23 } & React.RefAttributes<LegendListRef>) => React.ReactElement | null;
25diff --git a/keyboard.js b/keyboard.js
26index 6645bcbb1f77c36c432035eaf8b2d6d924fc8bda..74c1f568c485d0f907a0d3ea4ad600ccb8d3be62 100644
27--- a/keyboard.js
28+++ b/keyboard.js
29@@ -33,19 +33,19 @@ if (typeof __DEV__ !== "undefined" && __DEV__ && !reactNativeKeyboardController.
30 "[legend-list] KeyboardAwareLegendList requires a recent react-native-keyboard-controller with KeyboardChatScrollView. Please upgrade react-native-keyboard-controller to at least 1.21.7."
31 );
32 }
33-function useKeyboardChatComposerInset(listRef, composerRef, initialHeight = 0) {
34+function useKeyboardChatComposerInset(listRef, composerRef, initialHeight = 0, heightAdjustment = 0) {
35 const contentInsetEndAdjustment = reactNativeReanimated.useSharedValue(initialHeight);
36 const lastHeightRef = React.useRef(void 0);
37 const reportHeight = React.useCallback(
38- (height) => {
39+ (rawHeight) => {
40+ const height = Math.max(0, rawHeight + heightAdjustment);
41 var _a;
42 if (Number.isFinite(height) && height !== lastHeightRef.current) {
43 lastHeightRef.current = height;
44 contentInsetEndAdjustment.value = height;
45- (_a = listRef.current) == null ? void 0 : _a.reportContentInset({ bottom: height });
46 }
47 },
48- [contentInsetEndAdjustment, listRef]
49+ [contentInsetEndAdjustment, heightAdjustment, listRef]
50 );
51 React.useLayoutEffect(() => {
52 var _a;
53@@ -84,9 +84,11 @@ function useKeyboardScrollToEnd({ freeze: freezeProp, listRef }) {
54 }
55 var KeyboardAwareLegendList = typedForwardRef(function KeyboardAwareLegendList2(props, forwardedRef) {
56 const {
57+ adjustedInsetCompensation,
58 anchoredEndSpace,
59 applyWorkaroundForContentInsetHitTestBug,
60 contentInsetEndAdjustment,
61+ contentInsetEndStaticAdjustment,
62 freeze,
63 keyboardLiftBehavior,
64 keyboardOffset,
65@@ -108,11 +110,15 @@ var KeyboardAwareLegendList = typedForwardRef(function KeyboardAwareLegendList2(
66 ...anchoredEndSpace,
67 onSizeChanged: (size) => {
68 var _a;
69- blankSpace.value = size;
70+ // The anchored blank is sized against the ADJUSTED viewport, but the
71+ // scroll component writes it as a raw contentInset that UIKit tops up
72+ // with the safe-area bottom — write it net of that or the end rest
73+ // (and the anchored message) sinks one safe-area under the header.
74+ blankSpace.value = size > 0 ? Math.max(0, size - (adjustedInsetCompensation || 0)) : 0;
75 (_a = anchoredEndSpace.onSizeChanged) == null ? void 0 : _a.call(anchoredEndSpace, size);
76 }
77 };
78- }, [anchoredEndSpace, blankSpace]);
79+ }, [adjustedInsetCompensation, anchoredEndSpace, blankSpace]);
80 const onContentInsetChange = React.useCallback((insets) => {
81 var _a;
82 (_a = refLegendList.current) == null ? void 0 : _a.reportContentInset(insets);
83@@ -123,6 +129,7 @@ var KeyboardAwareLegendList = typedForwardRef(function KeyboardAwareLegendList2(
84 reactNativeKeyboardController.KeyboardChatScrollView,
85 {
86 ...scrollProps,
87+ adjustedInsetCompensation,
88 applyWorkaroundForContentInsetHitTestBug,
89 blankSpace,
90 extraContentPadding: contentInsetEndAdjustment,
91@@ -134,6 +141,7 @@ var KeyboardAwareLegendList = typedForwardRef(function KeyboardAwareLegendList2(
92 );
93 },
94 [
95+ adjustedInsetCompensation,
96 applyWorkaroundForContentInsetHitTestBug,
97 blankSpace,
98 contentInsetEndAdjustment,
99@@ -149,6 +157,7 @@ var KeyboardAwareLegendList = typedForwardRef(function KeyboardAwareLegendList2(
100 {
101 anchoredEndSpace: anchoredEndSpaceWithBlankSpace,
102 anchoredEndSpaceOwnerInternal: "scroll",
103+ contentInsetEndAdjustment: contentInsetEndStaticAdjustment,
104 ref: combinedRef,
105 renderScrollComponent: memoList,
106 ...rest
107diff --git a/keyboard.mjs b/keyboard.mjs
108index 87b38b9607c2eba6b407c2acfd520633bdb0e7c2..62206d657d5616893985fd2c228e57af7eba744b 100644
109--- a/keyboard.mjs
110+++ b/keyboard.mjs
111@@ -12,19 +12,19 @@ if (typeof __DEV__ !== "undefined" && __DEV__ && !KeyboardChatScrollView) {
112 "[legend-list] KeyboardAwareLegendList requires a recent react-native-keyboard-controller with KeyboardChatScrollView. Please upgrade react-native-keyboard-controller to at least 1.21.7."
113 );
114 }
115-function useKeyboardChatComposerInset(listRef, composerRef, initialHeight = 0) {
116+function useKeyboardChatComposerInset(listRef, composerRef, initialHeight = 0, heightAdjustment = 0) {
117 const contentInsetEndAdjustment = useSharedValue(initialHeight);
118 const lastHeightRef = useRef(void 0);
119 const reportHeight = useCallback(
120- (height) => {
121+ (rawHeight) => {
122+ const height = Math.max(0, rawHeight + heightAdjustment);
123 var _a;
124 if (Number.isFinite(height) && height !== lastHeightRef.current) {
125 lastHeightRef.current = height;
126 contentInsetEndAdjustment.value = height;
127- (_a = listRef.current) == null ? void 0 : _a.reportContentInset({ bottom: height });
128 }
129 },
130- [contentInsetEndAdjustment, listRef]
131+ [contentInsetEndAdjustment, heightAdjustment, listRef]
132 );
133 useLayoutEffect(() => {
134 var _a;
135@@ -63,9 +63,11 @@ function useKeyboardScrollToEnd({ freeze: freezeProp, listRef }) {
136 }
137 var KeyboardAwareLegendList = typedForwardRef(function KeyboardAwareLegendList2(props, forwardedRef) {
138 const {
139+ adjustedInsetCompensation,
140 anchoredEndSpace,
141 applyWorkaroundForContentInsetHitTestBug,
142 contentInsetEndAdjustment,
143+ contentInsetEndStaticAdjustment,
144 freeze,
145 keyboardLiftBehavior,
146 keyboardOffset,
147@@ -87,11 +89,15 @@ var KeyboardAwareLegendList = typedForwardRef(function KeyboardAwareLegendList2(
148 ...anchoredEndSpace,
149 onSizeChanged: (size) => {
150 var _a;
151- blankSpace.value = size;
152+ // The anchored blank is sized against the ADJUSTED viewport, but the
153+ // scroll component writes it as a raw contentInset that UIKit tops up
154+ // with the safe-area bottom — write it net of that or the end rest
155+ // (and the anchored message) sinks one safe-area under the header.
156+ blankSpace.value = size > 0 ? Math.max(0, size - (adjustedInsetCompensation || 0)) : 0;
157 (_a = anchoredEndSpace.onSizeChanged) == null ? void 0 : _a.call(anchoredEndSpace, size);
158 }
159 };
160- }, [anchoredEndSpace, blankSpace]);
161+ }, [adjustedInsetCompensation, anchoredEndSpace, blankSpace]);
162 const onContentInsetChange = useCallback((insets) => {
163 var _a;
164 (_a = refLegendList.current) == null ? void 0 : _a.reportContentInset(insets);
165@@ -102,6 +108,7 @@ var KeyboardAwareLegendList = typedForwardRef(function KeyboardAwareLegendList2(
166 KeyboardChatScrollView,
167 {
168 ...scrollProps,
169+ adjustedInsetCompensation,
170 applyWorkaroundForContentInsetHitTestBug,
171 blankSpace,
172 extraContentPadding: contentInsetEndAdjustment,
173@@ -113,6 +120,7 @@ var KeyboardAwareLegendList = typedForwardRef(function KeyboardAwareLegendList2(
174 );
175 },
176 [
177+ adjustedInsetCompensation,
178 applyWorkaroundForContentInsetHitTestBug,
179 blankSpace,
180 contentInsetEndAdjustment,
181@@ -128,6 +136,7 @@ var KeyboardAwareLegendList = typedForwardRef(function KeyboardAwareLegendList2(
182 {
183 anchoredEndSpace: anchoredEndSpaceWithBlankSpace,
184 anchoredEndSpaceOwnerInternal: "scroll",
185+ contentInsetEndAdjustment: contentInsetEndStaticAdjustment,
186 ref: combinedRef,
187 renderScrollComponent: memoList,
188 ...rest
189diff --git a/react-native.d.ts b/react-native.d.ts
190index ce1fe00001c9e5aee6c6ea8bb2d4757d4586d002..3ccf6f16067152dfcb0c143371e2ec6aba6636e5 100644
191--- a/react-native.d.ts
192+++ b/react-native.d.ts
193@@ -293,6 +293,12 @@ interface LegendListSpecificProps<ItemT, TItemType extends string | undefined> {
194 * The adjustment is also rendered as real content padding so the browser scroll range includes it.
195 */
196 contentInsetEndAdjustment?: number;
197+ /**
198+ * Width/height of a leading content inset applied natively outside the list's knowledge
199+ * (e.g. iOS contentInsetAdjustmentBehavior="automatic" under a transparent header).
200+ * Programmatic scrolls clamp to -adjustment instead of 0 so content can rest below the header.
201+ */
202+ contentInsetStartAdjustment?: number;
203 /**
204 * Number of columns to render items in.
205 * @default 1
206diff --git a/react-native.js b/react-native.js
207index b3c5a306b293f797a8b338adfca3060c0f6db22b..89077be4d6833cfaabf9d6d6205d9551505e32b4 100644
208--- a/react-native.js
209+++ b/react-native.js
210@@ -954,7 +954,7 @@ function setInitialRenderState(ctx, {
211 if (didInitialScroll) {
212 state.didFinishInitialScroll = true;
213 }
214- const isReadyToRender = Boolean(state.didContainersLayout && state.didFinishInitialScroll);
215+ const isReadyToRender = Boolean(state.didContainersLayout && state.didFinishInitialScroll && !state.insetEndRevealHold);
216 if (isReadyToRender && !peek$(ctx, "readyToRender")) {
217 set$(ctx, "readyToRender", true);
218 setAdaptiveRender(ctx, "normal", "ready");
219@@ -1304,18 +1304,23 @@ function calculateOffsetWithOffsetPosition(ctx, offsetParam, params) {
220 }
222 // src/core/clampScrollOffset.ts
223+function getContentInsetStartAdjustment(ctx) {
224+ const adjustment = ctx.state.props.contentInsetStartAdjustment;
225+ return typeof adjustment === "number" && Number.isFinite(adjustment) ? Math.max(0, adjustment) : 0;
226+}
227 function clampScrollOffset(ctx, offset, scrollTarget) {
228 const state = ctx.state;
229 const contentSize = getContentSize(ctx);
230+ const minOffset = -getContentInsetStartAdjustment(ctx);
231 let clampedOffset = offset;
232 if (Number.isFinite(contentSize) && Number.isFinite(state.scrollLength) && (Platform.OS !== "android" || state.lastLayout)) {
233- const baseMaxOffset = Math.max(0, contentSize - state.scrollLength);
234+ const baseMaxOffset = Math.max(minOffset, contentSize - state.scrollLength);
235 const viewOffset = scrollTarget == null ? void 0 : scrollTarget.viewOffset;
236 const extraEndOffset = typeof viewOffset === "number" && viewOffset < 0 ? -viewOffset : 0;
237 const maxOffset = baseMaxOffset + extraEndOffset;
238 clampedOffset = Math.min(offset, maxOffset);
239 }
240- clampedOffset = Math.max(0, clampedOffset);
241+ clampedOffset = Math.max(minOffset, clampedOffset);
242 return clampedOffset;
243 }
245@@ -1451,10 +1456,10 @@ function checkFinishedScrollFrame(ctx) {
246 finishScrollTo(ctx);
247 }
248 }
249-function scrollToFallbackOffset(ctx, offset) {
250+function scrollToFallbackOffset(ctx, offset, animated) {
251 var _a3;
252 (_a3 = ctx.state.refScroller.current) == null ? void 0 : _a3.scrollTo({
253- animated: false,
254+ animated: !!animated,
255 x: ctx.state.props.horizontal ? offset : 0,
256 y: ctx.state.props.horizontal ? 0 : offset
257 });
258@@ -1503,7 +1508,10 @@ function checkFinishedScrollFallback(ctx) {
259 );
260 scheduleFallbackCheck(SILENT_INITIAL_SCROLL_RETRY_DELAY_MS);
261 } else if (shouldRetryUnalignedEndScroll) {
262- scrollToFallbackOffset(ctx, completionState.clampedTargetOffset);
263+ const isActivelyAnimatingToEnd = !!isStillScrollingTo.animated && Date.now() - state.scrollTime < 100;
264+ if (!isActivelyAnimatingToEnd) {
265+ scrollToFallbackOffset(ctx, completionState.clampedTargetOffset, !!isStillScrollingTo.animated);
266+ }
267 scheduleFallbackCheck(100);
268 } else if (shouldFinishZeroTarget || shouldFinishAfterObservedScroll || canFinishInitialScrollWithoutNativeProgress || canFinishAfterSilentNativeDispatch || numChecks > maxChecks) {
269 finishScrollTo(ctx);
270@@ -1566,9 +1574,18 @@ function doMaintainScrollAtEnd(ctx) {
271 }
272 if (shouldMaintainScrollAtEnd) {
273 state.pendingMaintainScrollAtEnd = false;
274+ const maintainAnchoredEndSpace = state.props.anchoredEndSpace;
275+ const maintainAnchorIndex = maintainAnchoredEndSpace == null ? void 0 : maintainAnchoredEndSpace.anchorIndex;
276+ if (maintainAnchorIndex !== void 0 && maintainAnchorIndex >= 0 && maintainAnchorIndex < state.props.data.length && !areKnownOrFixedItemSizesAvailable(ctx, maintainAnchorIndex, state.props.data.length - 1)) {
277+ return false;
278+ }
279 const contentSize = getContentSize(ctx);
280+ const maintainInsetStartAdjustment = getContentInsetStartAdjustment(ctx);
281 if (contentSize < state.scrollLength) {
282- state.scroll = 0;
283+ state.scroll = -maintainInsetStartAdjustment;
284+ if (maintainInsetStartAdjustment > 0) {
285+ return true;
286+ }
287 }
288 if (!state.maintainingScrollAtEnd) {
289 const pendingState = maintainScrollAtEnd.animated ? "pending-animated" : "pending-instant";
290@@ -1591,9 +1608,18 @@ function doMaintainScrollAtEnd(ctx) {
291 y: 0
292 });
293 } else {
294- scroller == null ? void 0 : scroller.scrollToEnd({
295- animated: maintainScrollAtEnd.animated
296- });
297+ const insetStartAdjustment = getContentInsetStartAdjustment(ctx);
298+ if (insetStartAdjustment > 0) {
299+ scroller == null ? void 0 : scroller.scrollTo({
300+ animated: maintainScrollAtEnd.animated,
301+ x: 0,
302+ y: Math.max(-insetStartAdjustment, getContentSize(ctx) - state.scrollLength)
303+ });
304+ } else {
305+ scroller == null ? void 0 : scroller.scrollToEnd({
306+ animated: maintainScrollAtEnd.animated
307+ });
308+ }
309 }
310 setTimeout(
311 () => {
312@@ -1624,6 +1650,10 @@ function doMaintainScrollAtEnd(ctx) {
313 function requestAdjust(ctx, positionDiff, dataChanged) {
314 const state = ctx.state;
315 if (Math.abs(positionDiff) > 0.1) {
316+ // Timestamp for ReanimatedPositionView: repositions caused by an MVCP
317+ // size adjustment are already compensated by a contentOffset shift, so
318+ // animating them would make rows visibly lurch and slide back.
319+ state.lastMVCPAdjustTime = Date.now();
320 const needsScrollWorkaround = Platform.OS === "android" && !IsNewArchitecture && dataChanged && state.scroll <= positionDiff;
321 const doit = () => {
322 if (needsScrollWorkaround) {
323@@ -1728,7 +1758,9 @@ function getPredictedNativeClamp(state, unresolvedAmount, totalSize) {
324 if (Math.abs(unresolvedAmount) <= MVCP_POSITION_EPSILON) {
325 return 0;
326 }
327- const maxScroll = Math.max(0, totalSize - state.scrollLength);
328+ const insetStartAdjustment = state.props.contentInsetStartAdjustment;
329+ const minScroll = typeof insetStartAdjustment === "number" && Number.isFinite(insetStartAdjustment) ? -Math.max(0, insetStartAdjustment) : 0;
330+ const maxScroll = Math.max(minScroll, totalSize - state.scrollLength);
331 const clampDelta = maxScroll - state.scroll;
332 if (unresolvedAmount < 0) {
333 return Math.max(unresolvedAmount, Math.min(0, clampDelta));
334@@ -1790,7 +1822,7 @@ function resolvePendingNativeMVCPAdjust(ctx, newScroll) {
335 settlePendingNativeMVCPAdjust(ctx, remainingAfterManual, nativeDelta);
336 return true;
337 }
338- const expectedNativeClampScroll = Math.max(0, getContentSize(ctx) - state.scrollLength);
339+ const expectedNativeClampScroll = Math.max(-getContentInsetStartAdjustment(ctx), getContentSize(ctx) - state.scrollLength);
340 const distanceToClamp = Math.abs(newScroll - expectedNativeClampScroll);
341 const isAtExpectedNativeClamp = distanceToClamp <= NATIVE_END_CLAMP_EPSILON;
342 if (isAtExpectedNativeClamp) {
343@@ -1923,7 +1955,7 @@ function prepareMVCP(ctx, dataChanged) {
344 if (diff > 0) {
345 diff = Math.max(0, totalSize - state.scroll - state.scrollLength);
346 } else {
347- const maxScroll = Math.max(0, totalSize - state.scrollLength);
348+ const maxScroll = Math.max(-getContentInsetStartAdjustment(ctx), totalSize - state.scrollLength);
349 state.scroll = maxScroll;
350 state.scrollPending = maxScroll;
351 diff = 0;
352@@ -2320,8 +2352,121 @@ function scrollToIndex(ctx, {
353 }
355 // src/core/initialScroll.ts
356+var INSET_END_SETTLE_WATCHDOG_FRAMES = 150;
357+var INSET_END_SETTLE_WATCHDOG_STABLE_FRAMES = 20;
358+var INSET_END_REVEAL_STABLE_FRAMES = 3;
359+var INSET_END_REVEAL_MAX_HOLD_FRAMES = 40;
360+function startInsetEndSettleWatchdog(ctx) {
361+ const state = ctx.state;
362+ if (state.insetEndSettleWatchdogActive) {
363+ return;
364+ }
365+ state.insetEndSettleWatchdogActive = true;
366+ state.didUserDrag = false;
367+ // Hold the readyToRender opacity gate until the end landing is stable, so
368+ // the estimated-to-measured settle chase happens before first VISIBLE
369+ // paint instead of in front of the user. Capped so slow measurement can
370+ // never hide content for long.
371+ state.insetEndRevealHold = true;
372+ let frames = 0;
373+ let settledFrames = 0;
374+ let revealStableFrames = 0;
375+ const releaseRevealHold = () => {
376+ if (state.insetEndRevealHold) {
377+ state.insetEndRevealHold = false;
378+ setInitialRenderState(ctx, {});
379+ }
380+ };
381+ // Revealing flips adaptive rendering to "normal", which re-renders rows and
382+ // can move the end target one more time — do that upgrade while still
383+ // hidden (phase 1), then require stability again before revealing (phase 2)
384+ // so the first visible frame is the settled one.
385+ let revealPhase = 1;
386+ const onRevealStability = () => {
387+ var _a3;
388+ if (!state.insetEndRevealHold) {
389+ return;
390+ }
391+ if (revealPhase === 1) {
392+ revealPhase = 2;
393+ revealStableFrames = 0;
394+ setAdaptiveRender(ctx, "normal");
395+ (_a3 = state.triggerCalculateItemsInView) == null ? void 0 : _a3.call(state);
396+ return;
397+ }
398+ releaseRevealHold();
399+ };
400+ const tick = () => {
401+ // The user owns the scroll from their first drag — a re-pin here would
402+ // pin the list under their finger.
403+ if (frames++ >= INSET_END_SETTLE_WATCHDOG_FRAMES || settledFrames >= INSET_END_SETTLE_WATCHDOG_STABLE_FRAMES || state.didUserDrag || !ctx.state || ctx.state !== state) {
404+ state.insetEndSettleWatchdogActive = false;
405+ releaseRevealHold();
406+ return;
407+ }
408+ if (frames >= INSET_END_REVEAL_MAX_HOLD_FRAMES) {
409+ releaseRevealHold();
410+ }
411+ const insetStartAdjustment = getContentInsetStartAdjustment(ctx);
412+ const contentSize = getContentSize(ctx);
413+ const scrollLength = state.scrollLength;
414+ if (insetStartAdjustment > 0 && scrollLength > 0 && Number.isFinite(contentSize) && contentSize > scrollLength && !state.scrollingTo && !state.maintainingScrollAtEnd) {
415+ const endOffset = Math.max(-insetStartAdjustment, contentSize - scrollLength);
416+ const distance = endOffset - state.scroll;
417+ // Estimated row sizes converging to measured ones can strand the initial
418+ // end landing when the library's own end-anchor bookkeeping gives up.
419+ // While still near the end (never fighting a user who scrolled away),
420+ // re-pin to the current true end until sizes stop changing.
421+ if (Math.abs(distance) > 2 && Math.abs(distance) <= scrollLength * 0.5) {
422+ settledFrames = 0;
423+ revealStableFrames = 0;
424+ const scroller = state.refScroller.current;
425+ if (scroller) {
426+ scroller.scrollTo({ animated: false, x: 0, y: endOffset });
427+ }
428+ } else {
429+ settledFrames++;
430+ revealStableFrames++;
431+ if (revealStableFrames >= INSET_END_REVEAL_STABLE_FRAMES) {
432+ onRevealStability();
433+ }
434+ }
435+ } else {
436+ // Conditions that make re-pinning unnecessary (underflow, in-flight
437+ // programmatic scroll) count toward stability for the reveal.
438+ revealStableFrames++;
439+ if (revealStableFrames >= INSET_END_REVEAL_STABLE_FRAMES) {
440+ onRevealStability();
441+ }
442+ }
443+ requestAnimationFrame(tick);
444+ };
445+ requestAnimationFrame(tick);
446+}
447 function dispatchInitialScroll(ctx, params) {
448 const { forceScroll, resolvedOffset, target, waitForCompletionFrame } = params;
449+ const insetStartAdjustment = getContentInsetStartAdjustment(ctx);
450+ if (insetStartAdjustment > 0 && ctx.state.props.data.length > 0) {
451+ if (ctx.state.scrollLength <= 0) {
452+ // The scroll length is unknown, so the resolved target is meaningless;
453+ // the initial-scroll machinery re-advances after layout.
454+ return;
455+ }
456+ if (resolvedOffset <= -insetStartAdjustment + 1 && !ctx.state.didDispatchInsetInitialScroll) {
457+ // Content underflows the viewport and nothing has scrolled yet: the
458+ // untouched native rest position (UIKit's adjustedContentInset) IS the
459+ // end position. Dispatching a negative scroll here would race UIKit's
460+ // inset application during screen attach, so just finish the session.
461+ finishInitialScroll(ctx, {
462+ resolvedOffset
463+ });
464+ return;
465+ }
466+ ctx.state.didDispatchInsetInitialScroll = true;
467+ if (target.viewPosition === 1) {
468+ startInsetEndSettleWatchdog(ctx);
469+ }
470+ }
471 const requestedIndex = target.index;
472 const index = requestedIndex !== void 0 ? clampScrollIndex(requestedIndex, ctx.state.props.data.length) : void 0;
473 const itemSize = getItemSizeAtIndex(ctx, index);
474@@ -2747,7 +2892,9 @@ function clearFinishedBootstrapInitialScrollTargetIfMovedAway(ctx) {
475 return;
476 }
477 if (didFinishedInitialScrollMoveAwayFromTarget(ctx, initialScroll)) {
478- const shouldKeepEndTargetAlive = isRetargetableBottomAlignedInitialScrollTarget(initialScroll) && peek$(ctx, "isAtEnd");
479+ const endTargetDistanceFromEnd = getContentSize(ctx) - state.scroll - state.scrollLength - getContentInsetEnd(ctx);
480+ const isNearEndForInsetList = getContentInsetStartAdjustment(ctx) > 0 && Number.isFinite(endTargetDistanceFromEnd) && endTargetDistanceFromEnd <= state.scrollLength * 0.5;
481+ const shouldKeepEndTargetAlive = isRetargetableBottomAlignedInitialScrollTarget(initialScroll) && (peek$(ctx, "isAtEnd") || isNearEndForInsetList);
482 if (!shouldKeepEndTargetAlive) {
483 if (shouldPreserveInitialScrollForFooterLayout(initialScroll)) {
484 clearPendingInitialScrollFooterLayout(ctx, {
485@@ -4672,7 +4819,8 @@ function maybeUpdateAnchoredEndSpace(ctx) {
486 contentBelowAnchor = Math.max(0, contentBelowAnchor - ctx.scrollAxisGap);
487 contentBelowAnchor += (ctx.values.get("footerSize") || 0) + getStylePaddingEnd(state.props);
488 isReady = !hasUnknownTailSize;
489- nextSize = hasUnknownTailSize ? previousSize || 0 : Math.max(0, state.scrollLength - contentBelowAnchor - anchorOffset);
490+ const knownSizeBound = Math.max(0, state.scrollLength - contentBelowAnchor - anchorOffset);
491+ nextSize = hasUnknownTailSize ? Math.min(previousSize || 0, knownSizeBound) : knownSizeBound;
492 } else if (anchorIndex >= 0) {
493 isReady = false;
494 }
495@@ -4692,6 +4840,12 @@ function maybeUpdateAnchoredEndSpace(ctx) {
496 updateScroll(ctx, state.scroll, true, { markHasScrolled: false });
497 }
498 (_b = anchoredEndSpace == null ? void 0 : anchoredEndSpace.onReady) == null ? void 0 : _b.call(anchoredEndSpace, { anchorIndex: nextAnchorIndex, anchorKey: nextAnchorKey, size: nextSize });
499+ } else if (!isReady && didSizeChange && nextSize < (previousSize || 0)) {
500+ set$(ctx, "anchoredEndSpaceSize", nextSize);
501+ (_a3 = anchoredEndSpace == null ? void 0 : anchoredEndSpace.onSizeChanged) == null ? void 0 : _a3.call(anchoredEndSpace, nextSize);
502+ if (anchoredEndSpace == null ? void 0 : anchoredEndSpace.includeInEndInset) {
503+ updateScroll(ctx, state.scroll, true, { markHasScrolled: false });
504+ }
505 }
506 return nextSize;
507 }
508@@ -7075,6 +7229,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
509 dataVersion,
510 drawDistance = 250,
511 contentInsetEndAdjustment,
512+ contentInsetStartAdjustment,
513 estimatedItemSize = 100,
514 estimatedListSize,
515 extraData,
516@@ -7105,6 +7260,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
517 onLayout: onLayoutProp,
518 onLoad,
519 onMomentumScrollEnd,
520+ onScrollBeginDrag,
521 onRefresh,
522 onScroll: onScrollProp,
523 onScrollBeginDrag,
524@@ -7200,7 +7356,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
525 const combinedRef = useCombinedRef(refScroller, refScrollView);
526 const keyExtractor = keyExtractorProp != null ? keyExtractorProp : ((_item, index) => index.toString());
527 const stickyHeaderIndices = stickyHeaderIndicesProp;
528- const contentInsetEndAdjustmentResolved = Platform.OS === "web" ? contentInsetEndAdjustment : void 0;
529+ const contentInsetEndAdjustmentResolved = contentInsetEndAdjustment;
530 const previousContentInsetEndAdjustmentRef = React2.useRef(contentInsetEndAdjustmentResolved);
531 const alwaysRenderIndices = React2.useMemo(() => {
532 const indices = getAlwaysRenderIndices(alwaysRender, dataProp, keyExtractor, anchoredEndSpace == null ? void 0 : anchoredEndSpace.anchorIndex);
533@@ -7341,6 +7497,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
534 contentContainerAlignItems: contentContainerStyle.alignItems,
535 contentInset,
536 contentInsetEndAdjustment: contentInsetEndAdjustmentResolved,
537+ contentInsetStartAdjustment,
538 data: dataProp,
539 dataKey,
540 dataVersion,
541@@ -7423,6 +7580,13 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
542 return void 0;
543 }
544 const resolvedOffset = (_a4 = initialScroll.contentOffset) != null ? _a4 : resolveInitialScrollOffset(ctx, initialScroll);
545+ if (getContentInsetStartAdjustment(ctx) > 0) {
546+ // With a native leading inset (transparent header + automatic insets),
547+ // any mount-time contentOffset races UIKit's adjustedContentInset
548+ // application. The gated initial-scroll dispatch positions the list once
549+ // real sizes are known instead.
550+ return void 0;
551+ }
552 return usesBootstrapInitialScroll && ((_b2 = state.initialScrollSession) == null ? void 0 : _b2.kind) === "bootstrap" && Platform.OS === "web" ? void 0 : resolvedOffset;
553 }, [usesBootstrapInitialScroll]);
554 React2.useLayoutEffect(() => {
555@@ -7651,6 +7815,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
556 onScroll: (event) => onScroll(ctx, event),
557 onScrollBeginDrag: (event) => {
558 var _a4, _b2;
559+ ctx.state.didUserDrag = true;
560 prepareReachedEdgeForNextUserScroll(ctx);
561 (_b2 = (_a4 = state.props).onScrollBeginDrag) == null ? void 0 : _b2.call(_a4, event);
562 },
563@@ -7681,6 +7846,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
564 onLayout,
565 onLayoutFooter,
566 onMomentumScrollEnd: fns.onMomentumScrollEnd,
567+ onScrollBeginDrag: fns.onScrollBeginDrag,
568 onScroll: onScrollHandler,
569 recycleItems,
570 refreshControl: refreshControlElement ? stylePaddingTopState > 0 ? React2__namespace.cloneElement(refreshControlElement, {
571diff --git a/react-native.mjs b/react-native.mjs
572index 40e87cda8c9bc79a889e5542f29af429a24b24d4..2d556eecb0bafe2f54084c809f82144c7a5dce7f 100644
573--- a/react-native.mjs
574+++ b/react-native.mjs
575@@ -933,7 +933,7 @@ function setInitialRenderState(ctx, {
576 if (didInitialScroll) {
577 state.didFinishInitialScroll = true;
578 }
579- const isReadyToRender = Boolean(state.didContainersLayout && state.didFinishInitialScroll);
580+ const isReadyToRender = Boolean(state.didContainersLayout && state.didFinishInitialScroll && !state.insetEndRevealHold);
581 if (isReadyToRender && !peek$(ctx, "readyToRender")) {
582 set$(ctx, "readyToRender", true);
583 setAdaptiveRender(ctx, "normal", "ready");
584@@ -1283,18 +1283,23 @@ function calculateOffsetWithOffsetPosition(ctx, offsetParam, params) {
585 }
587 // src/core/clampScrollOffset.ts
588+function getContentInsetStartAdjustment(ctx) {
589+ const adjustment = ctx.state.props.contentInsetStartAdjustment;
590+ return typeof adjustment === "number" && Number.isFinite(adjustment) ? Math.max(0, adjustment) : 0;
591+}
592 function clampScrollOffset(ctx, offset, scrollTarget) {
593 const state = ctx.state;
594 const contentSize = getContentSize(ctx);
595+ const minOffset = -getContentInsetStartAdjustment(ctx);
596 let clampedOffset = offset;
597 if (Number.isFinite(contentSize) && Number.isFinite(state.scrollLength) && (Platform.OS !== "android" || state.lastLayout)) {
598- const baseMaxOffset = Math.max(0, contentSize - state.scrollLength);
599+ const baseMaxOffset = Math.max(minOffset, contentSize - state.scrollLength);
600 const viewOffset = scrollTarget == null ? void 0 : scrollTarget.viewOffset;
601 const extraEndOffset = typeof viewOffset === "number" && viewOffset < 0 ? -viewOffset : 0;
602 const maxOffset = baseMaxOffset + extraEndOffset;
603 clampedOffset = Math.min(offset, maxOffset);
604 }
605- clampedOffset = Math.max(0, clampedOffset);
606+ clampedOffset = Math.max(minOffset, clampedOffset);
607 return clampedOffset;
608 }
610@@ -1430,10 +1435,10 @@ function checkFinishedScrollFrame(ctx) {
611 finishScrollTo(ctx);
612 }
613 }
614-function scrollToFallbackOffset(ctx, offset) {
615+function scrollToFallbackOffset(ctx, offset, animated) {
616 var _a3;
617 (_a3 = ctx.state.refScroller.current) == null ? void 0 : _a3.scrollTo({
618- animated: false,
619+ animated: !!animated,
620 x: ctx.state.props.horizontal ? offset : 0,
621 y: ctx.state.props.horizontal ? 0 : offset
622 });
623@@ -1482,7 +1487,10 @@ function checkFinishedScrollFallback(ctx) {
624 );
625 scheduleFallbackCheck(SILENT_INITIAL_SCROLL_RETRY_DELAY_MS);
626 } else if (shouldRetryUnalignedEndScroll) {
627- scrollToFallbackOffset(ctx, completionState.clampedTargetOffset);
628+ const isActivelyAnimatingToEnd = !!isStillScrollingTo.animated && Date.now() - state.scrollTime < 100;
629+ if (!isActivelyAnimatingToEnd) {
630+ scrollToFallbackOffset(ctx, completionState.clampedTargetOffset, !!isStillScrollingTo.animated);
631+ }
632 scheduleFallbackCheck(100);
633 } else if (shouldFinishZeroTarget || shouldFinishAfterObservedScroll || canFinishInitialScrollWithoutNativeProgress || canFinishAfterSilentNativeDispatch || numChecks > maxChecks) {
634 finishScrollTo(ctx);
635@@ -1545,9 +1553,18 @@ function doMaintainScrollAtEnd(ctx) {
636 }
637 if (shouldMaintainScrollAtEnd) {
638 state.pendingMaintainScrollAtEnd = false;
639+ const maintainAnchoredEndSpace = state.props.anchoredEndSpace;
640+ const maintainAnchorIndex = maintainAnchoredEndSpace == null ? void 0 : maintainAnchoredEndSpace.anchorIndex;
641+ if (maintainAnchorIndex !== void 0 && maintainAnchorIndex >= 0 && maintainAnchorIndex < state.props.data.length && !areKnownOrFixedItemSizesAvailable(ctx, maintainAnchorIndex, state.props.data.length - 1)) {
642+ return false;
643+ }
644 const contentSize = getContentSize(ctx);
645+ const maintainInsetStartAdjustment = getContentInsetStartAdjustment(ctx);
646 if (contentSize < state.scrollLength) {
647- state.scroll = 0;
648+ state.scroll = -maintainInsetStartAdjustment;
649+ if (maintainInsetStartAdjustment > 0) {
650+ return true;
651+ }
652 }
653 if (!state.maintainingScrollAtEnd) {
654 const pendingState = maintainScrollAtEnd.animated ? "pending-animated" : "pending-instant";
655@@ -1570,9 +1587,18 @@ function doMaintainScrollAtEnd(ctx) {
656 y: 0
657 });
658 } else {
659- scroller == null ? void 0 : scroller.scrollToEnd({
660- animated: maintainScrollAtEnd.animated
661- });
662+ const insetStartAdjustment = getContentInsetStartAdjustment(ctx);
663+ if (insetStartAdjustment > 0) {
664+ scroller == null ? void 0 : scroller.scrollTo({
665+ animated: maintainScrollAtEnd.animated,
666+ x: 0,
667+ y: Math.max(-insetStartAdjustment, getContentSize(ctx) - state.scrollLength)
668+ });
669+ } else {
670+ scroller == null ? void 0 : scroller.scrollToEnd({
671+ animated: maintainScrollAtEnd.animated
672+ });
673+ }
674 }
675 setTimeout(
676 () => {
677@@ -1603,6 +1629,10 @@ function doMaintainScrollAtEnd(ctx) {
678 function requestAdjust(ctx, positionDiff, dataChanged) {
679 const state = ctx.state;
680 if (Math.abs(positionDiff) > 0.1) {
681+ // Timestamp for ReanimatedPositionView: repositions caused by an MVCP
682+ // size adjustment are already compensated by a contentOffset shift, so
683+ // animating them would make rows visibly lurch and slide back.
684+ state.lastMVCPAdjustTime = Date.now();
685 const needsScrollWorkaround = Platform.OS === "android" && !IsNewArchitecture && dataChanged && state.scroll <= positionDiff;
686 const doit = () => {
687 if (needsScrollWorkaround) {
688@@ -1707,7 +1737,9 @@ function getPredictedNativeClamp(state, unresolvedAmount, totalSize) {
689 if (Math.abs(unresolvedAmount) <= MVCP_POSITION_EPSILON) {
690 return 0;
691 }
692- const maxScroll = Math.max(0, totalSize - state.scrollLength);
693+ const insetStartAdjustment = state.props.contentInsetStartAdjustment;
694+ const minScroll = typeof insetStartAdjustment === "number" && Number.isFinite(insetStartAdjustment) ? -Math.max(0, insetStartAdjustment) : 0;
695+ const maxScroll = Math.max(minScroll, totalSize - state.scrollLength);
696 const clampDelta = maxScroll - state.scroll;
697 if (unresolvedAmount < 0) {
698 return Math.max(unresolvedAmount, Math.min(0, clampDelta));
699@@ -1769,7 +1801,7 @@ function resolvePendingNativeMVCPAdjust(ctx, newScroll) {
700 settlePendingNativeMVCPAdjust(ctx, remainingAfterManual, nativeDelta);
701 return true;
702 }
703- const expectedNativeClampScroll = Math.max(0, getContentSize(ctx) - state.scrollLength);
704+ const expectedNativeClampScroll = Math.max(-getContentInsetStartAdjustment(ctx), getContentSize(ctx) - state.scrollLength);
705 const distanceToClamp = Math.abs(newScroll - expectedNativeClampScroll);
706 const isAtExpectedNativeClamp = distanceToClamp <= NATIVE_END_CLAMP_EPSILON;
707 if (isAtExpectedNativeClamp) {
708@@ -1902,7 +1934,7 @@ function prepareMVCP(ctx, dataChanged) {
709 if (diff > 0) {
710 diff = Math.max(0, totalSize - state.scroll - state.scrollLength);
711 } else {
712- const maxScroll = Math.max(0, totalSize - state.scrollLength);
713+ const maxScroll = Math.max(-getContentInsetStartAdjustment(ctx), totalSize - state.scrollLength);
714 state.scroll = maxScroll;
715 state.scrollPending = maxScroll;
716 diff = 0;
717@@ -2299,8 +2331,121 @@ function scrollToIndex(ctx, {
718 }
720 // src/core/initialScroll.ts
721+var INSET_END_SETTLE_WATCHDOG_FRAMES = 150;
722+var INSET_END_SETTLE_WATCHDOG_STABLE_FRAMES = 20;
723+var INSET_END_REVEAL_STABLE_FRAMES = 3;
724+var INSET_END_REVEAL_MAX_HOLD_FRAMES = 40;
725+function startInsetEndSettleWatchdog(ctx) {
726+ const state = ctx.state;
727+ if (state.insetEndSettleWatchdogActive) {
728+ return;
729+ }
730+ state.insetEndSettleWatchdogActive = true;
731+ state.didUserDrag = false;
732+ // Hold the readyToRender opacity gate until the end landing is stable, so
733+ // the estimated-to-measured settle chase happens before first VISIBLE
734+ // paint instead of in front of the user. Capped so slow measurement can
735+ // never hide content for long.
736+ state.insetEndRevealHold = true;
737+ let frames = 0;
738+ let settledFrames = 0;
739+ let revealStableFrames = 0;
740+ const releaseRevealHold = () => {
741+ if (state.insetEndRevealHold) {
742+ state.insetEndRevealHold = false;
743+ setInitialRenderState(ctx, {});
744+ }
745+ };
746+ // Revealing flips adaptive rendering to "normal", which re-renders rows and
747+ // can move the end target one more time — do that upgrade while still
748+ // hidden (phase 1), then require stability again before revealing (phase 2)
749+ // so the first visible frame is the settled one.
750+ let revealPhase = 1;
751+ const onRevealStability = () => {
752+ var _a3;
753+ if (!state.insetEndRevealHold) {
754+ return;
755+ }
756+ if (revealPhase === 1) {
757+ revealPhase = 2;
758+ revealStableFrames = 0;
759+ setAdaptiveRender(ctx, "normal");
760+ (_a3 = state.triggerCalculateItemsInView) == null ? void 0 : _a3.call(state);
761+ return;
762+ }
763+ releaseRevealHold();
764+ };
765+ const tick = () => {
766+ // The user owns the scroll from their first drag — a re-pin here would
767+ // pin the list under their finger.
768+ if (frames++ >= INSET_END_SETTLE_WATCHDOG_FRAMES || settledFrames >= INSET_END_SETTLE_WATCHDOG_STABLE_FRAMES || state.didUserDrag || !ctx.state || ctx.state !== state) {
769+ state.insetEndSettleWatchdogActive = false;
770+ releaseRevealHold();
771+ return;
772+ }
773+ if (frames >= INSET_END_REVEAL_MAX_HOLD_FRAMES) {
774+ releaseRevealHold();
775+ }
776+ const insetStartAdjustment = getContentInsetStartAdjustment(ctx);
777+ const contentSize = getContentSize(ctx);
778+ const scrollLength = state.scrollLength;
779+ if (insetStartAdjustment > 0 && scrollLength > 0 && Number.isFinite(contentSize) && contentSize > scrollLength && !state.scrollingTo && !state.maintainingScrollAtEnd) {
780+ const endOffset = Math.max(-insetStartAdjustment, contentSize - scrollLength);
781+ const distance = endOffset - state.scroll;
782+ // Estimated row sizes converging to measured ones can strand the initial
783+ // end landing when the library's own end-anchor bookkeeping gives up.
784+ // While still near the end (never fighting a user who scrolled away),
785+ // re-pin to the current true end until sizes stop changing.
786+ if (Math.abs(distance) > 2 && Math.abs(distance) <= scrollLength * 0.5) {
787+ settledFrames = 0;
788+ revealStableFrames = 0;
789+ const scroller = state.refScroller.current;
790+ if (scroller) {
791+ scroller.scrollTo({ animated: false, x: 0, y: endOffset });
792+ }
793+ } else {
794+ settledFrames++;
795+ revealStableFrames++;
796+ if (revealStableFrames >= INSET_END_REVEAL_STABLE_FRAMES) {
797+ onRevealStability();
798+ }
799+ }
800+ } else {
801+ // Conditions that make re-pinning unnecessary (underflow, in-flight
802+ // programmatic scroll) count toward stability for the reveal.
803+ revealStableFrames++;
804+ if (revealStableFrames >= INSET_END_REVEAL_STABLE_FRAMES) {
805+ onRevealStability();
806+ }
807+ }
808+ requestAnimationFrame(tick);
809+ };
810+ requestAnimationFrame(tick);
811+}
812 function dispatchInitialScroll(ctx, params) {
813 const { forceScroll, resolvedOffset, target, waitForCompletionFrame } = params;
814+ const insetStartAdjustment = getContentInsetStartAdjustment(ctx);
815+ if (insetStartAdjustment > 0 && ctx.state.props.data.length > 0) {
816+ if (ctx.state.scrollLength <= 0) {
817+ // The scroll length is unknown, so the resolved target is meaningless;
818+ // the initial-scroll machinery re-advances after layout.
819+ return;
820+ }
821+ if (resolvedOffset <= -insetStartAdjustment + 1 && !ctx.state.didDispatchInsetInitialScroll) {
822+ // Content underflows the viewport and nothing has scrolled yet: the
823+ // untouched native rest position (UIKit's adjustedContentInset) IS the
824+ // end position. Dispatching a negative scroll here would race UIKit's
825+ // inset application during screen attach, so just finish the session.
826+ finishInitialScroll(ctx, {
827+ resolvedOffset
828+ });
829+ return;
830+ }
831+ ctx.state.didDispatchInsetInitialScroll = true;
832+ if (target.viewPosition === 1) {
833+ startInsetEndSettleWatchdog(ctx);
834+ }
835+ }
836 const requestedIndex = target.index;
837 const index = requestedIndex !== void 0 ? clampScrollIndex(requestedIndex, ctx.state.props.data.length) : void 0;
838 const itemSize = getItemSizeAtIndex(ctx, index);
839@@ -2726,7 +2871,9 @@ function clearFinishedBootstrapInitialScrollTargetIfMovedAway(ctx) {
840 return;
841 }
842 if (didFinishedInitialScrollMoveAwayFromTarget(ctx, initialScroll)) {
843- const shouldKeepEndTargetAlive = isRetargetableBottomAlignedInitialScrollTarget(initialScroll) && peek$(ctx, "isAtEnd");
844+ const endTargetDistanceFromEnd = getContentSize(ctx) - state.scroll - state.scrollLength - getContentInsetEnd(ctx);
845+ const isNearEndForInsetList = getContentInsetStartAdjustment(ctx) > 0 && Number.isFinite(endTargetDistanceFromEnd) && endTargetDistanceFromEnd <= state.scrollLength * 0.5;
846+ const shouldKeepEndTargetAlive = isRetargetableBottomAlignedInitialScrollTarget(initialScroll) && (peek$(ctx, "isAtEnd") || isNearEndForInsetList);
847 if (!shouldKeepEndTargetAlive) {
848 if (shouldPreserveInitialScrollForFooterLayout(initialScroll)) {
849 clearPendingInitialScrollFooterLayout(ctx, {
850@@ -4651,7 +4798,8 @@ function maybeUpdateAnchoredEndSpace(ctx) {
851 contentBelowAnchor = Math.max(0, contentBelowAnchor - ctx.scrollAxisGap);
852 contentBelowAnchor += (ctx.values.get("footerSize") || 0) + getStylePaddingEnd(state.props);
853 isReady = !hasUnknownTailSize;
854- nextSize = hasUnknownTailSize ? previousSize || 0 : Math.max(0, state.scrollLength - contentBelowAnchor - anchorOffset);
855+ const knownSizeBound = Math.max(0, state.scrollLength - contentBelowAnchor - anchorOffset);
856+ nextSize = hasUnknownTailSize ? Math.min(previousSize || 0, knownSizeBound) : knownSizeBound;
857 } else if (anchorIndex >= 0) {
858 isReady = false;
859 }
860@@ -4671,6 +4819,12 @@ function maybeUpdateAnchoredEndSpace(ctx) {
861 updateScroll(ctx, state.scroll, true, { markHasScrolled: false });
862 }
863 (_b = anchoredEndSpace == null ? void 0 : anchoredEndSpace.onReady) == null ? void 0 : _b.call(anchoredEndSpace, { anchorIndex: nextAnchorIndex, anchorKey: nextAnchorKey, size: nextSize });
864+ } else if (!isReady && didSizeChange && nextSize < (previousSize || 0)) {
865+ set$(ctx, "anchoredEndSpaceSize", nextSize);
866+ (_a3 = anchoredEndSpace == null ? void 0 : anchoredEndSpace.onSizeChanged) == null ? void 0 : _a3.call(anchoredEndSpace, nextSize);
867+ if (anchoredEndSpace == null ? void 0 : anchoredEndSpace.includeInEndInset) {
868+ updateScroll(ctx, state.scroll, true, { markHasScrolled: false });
869+ }
870 }
871 return nextSize;
872 }
873@@ -7054,6 +7208,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
874 dataVersion,
875 drawDistance = 250,
876 contentInsetEndAdjustment,
877+ contentInsetStartAdjustment,
878 estimatedItemSize = 100,
879 estimatedListSize,
880 extraData,
881@@ -7179,7 +7334,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
882 const combinedRef = useCombinedRef(refScroller, refScrollView);
883 const keyExtractor = keyExtractorProp != null ? keyExtractorProp : ((_item, index) => index.toString());
884 const stickyHeaderIndices = stickyHeaderIndicesProp;
885- const contentInsetEndAdjustmentResolved = Platform.OS === "web" ? contentInsetEndAdjustment : void 0;
886+ const contentInsetEndAdjustmentResolved = contentInsetEndAdjustment;
887 const previousContentInsetEndAdjustmentRef = useRef(contentInsetEndAdjustmentResolved);
888 const alwaysRenderIndices = useMemo(() => {
889 const indices = getAlwaysRenderIndices(alwaysRender, dataProp, keyExtractor, anchoredEndSpace == null ? void 0 : anchoredEndSpace.anchorIndex);
890@@ -7320,6 +7475,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
891 contentContainerAlignItems: contentContainerStyle.alignItems,
892 contentInset,
893 contentInsetEndAdjustment: contentInsetEndAdjustmentResolved,
894+ contentInsetStartAdjustment,
895 data: dataProp,
896 dataKey,
897 dataVersion,
898@@ -7402,6 +7558,13 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
899 return void 0;
900 }
901 const resolvedOffset = (_a4 = initialScroll.contentOffset) != null ? _a4 : resolveInitialScrollOffset(ctx, initialScroll);
902+ if (getContentInsetStartAdjustment(ctx) > 0) {
903+ // With a native leading inset (transparent header + automatic insets),
904+ // any mount-time contentOffset races UIKit's adjustedContentInset
905+ // application. The gated initial-scroll dispatch positions the list once
906+ // real sizes are known instead.
907+ return void 0;
908+ }
909 return usesBootstrapInitialScroll && ((_b2 = state.initialScrollSession) == null ? void 0 : _b2.kind) === "bootstrap" && Platform.OS === "web" ? void 0 : resolvedOffset;
910 }, [usesBootstrapInitialScroll]);
911 useLayoutEffect(() => {
912@@ -7630,6 +7793,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
913 onScroll: (event) => onScroll(ctx, event),
914 onScrollBeginDrag: (event) => {
915 var _a4, _b2;
916+ ctx.state.didUserDrag = true;
917 prepareReachedEdgeForNextUserScroll(ctx);
918 (_b2 = (_a4 = state.props).onScrollBeginDrag) == null ? void 0 : _b2.call(_a4, event);
919 },
920@@ -7660,6 +7824,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
921 onLayout,
922 onLayoutFooter,
923 onMomentumScrollEnd: fns.onMomentumScrollEnd,
924+ onScrollBeginDrag: fns.onScrollBeginDrag,
925 onScroll: onScrollHandler,
926 recycleItems,
927 refreshControl: refreshControlElement ? stylePaddingTopState > 0 ? React2.cloneElement(refreshControlElement, {
928diff --git a/reanimated.d.ts b/reanimated.d.ts
929index e5043320700b12f34f4c0babbc341f85ca8135c1..2ce63830a28636b21937a0741fd0e613dae950fe 100644
930--- a/reanimated.d.ts
931+++ b/reanimated.d.ts
932@@ -294,6 +294,12 @@ interface LegendListSpecificProps<ItemT, TItemType extends string | undefined> {
933 * The adjustment is also rendered as real content padding so the browser scroll range includes it.
934 */
935 contentInsetEndAdjustment?: number;
936+ /**
937+ * Width/height of a leading content inset applied natively outside the list's knowledge
938+ * (e.g. iOS contentInsetAdjustmentBehavior="automatic" under a transparent header).
939+ * Programmatic scrolls clamp to -adjustment instead of 0 so content can rest below the header.
940+ */
941+ contentInsetStartAdjustment?: number;
942 /**
943 * Number of columns to render items in.
944 * @default 1
945diff --git a/reanimated.js b/reanimated.js
946index f1265fad74189591b5aae86cf2e3a31f9c0fdb02..16dcef04a6591d500c724635df272274123bad2d 100644
947--- a/reanimated.js
948+++ b/reanimated.js
949@@ -116,7 +116,7 @@ var ReanimatedPositionView = typedMemo(function ReanimatedPositionViewComponent(
950 const [positionValue = POSITION_OUT_OF_VIEW] = useArr$([`containerPosition${id}`]);
951 const prevItemKeyRef = React__namespace.useRef(void 0);
952 let shouldSkipTransitionForRecycleReuse = false;
953- if (recycleItems && layoutTransition) {
954+ if (layoutTransition) {
955 const itemKeySignal = `containerItemKey${id}`;
956 const itemKey = peek$(ctx, itemKeySignal);
957 shouldSkipTransitionForRecycleReuse = itemKey !== void 0 && prevItemKeyRef.current !== void 0 && prevItemKeyRef.current !== itemKey;
958@@ -130,10 +130,20 @@ var ReanimatedPositionView = typedMemo(function ReanimatedPositionViewComponent(
959 () => [style, horizontal ? { left: positionValue } : { top: positionValue }],
960 [horizontal, positionValue, style]
961 );
962+ // Two kinds of repositions must not animate: (1) MVCP size adjustments,
963+ // which are compensated by an equal contentOffset shift so the row should
964+ // not visibly move — animating turns the invisible correction into a
965+ // lurch-and-settle; (2) any reposition while the user is actively
966+ // scrolling, where rows shifting under the finger reads as jank. The
967+ // transition exists to smooth at-rest shifts (streaming text, work-log
968+ // folds), so gate it to at-rest moments.
969+ const now = Date.now();
970+ const isMVCPReposition = now - (ctx.state.lastMVCPAdjustTime || 0) < 300 ||
971+ now - (ctx.state.lastNativeScrollTime || 0) < 300;
972 return /* @__PURE__ */ React__namespace.createElement(
973 Reanimated__default.default.View,
974 {
975- layout: shouldSkipTransitionForRecycleReuse ? void 0 : layoutTransition,
976+ layout: shouldSkipTransitionForRecycleReuse || isMVCPReposition ? void 0 : layoutTransition,
977 ref: refView,
978 style: viewStyle,
979 ...rest
980diff --git a/reanimated.mjs b/reanimated.mjs
981index 29a00d5dc084fd408a0e0a0a4d64e856d0ed1525..9c25ec5dd79fb137c073adc24643ad8a2996bf56 100644
982--- a/reanimated.mjs
983+++ b/reanimated.mjs
984@@ -92,7 +92,7 @@ var ReanimatedPositionView = typedMemo(function ReanimatedPositionViewComponent(
985 const [positionValue = POSITION_OUT_OF_VIEW] = useArr$([`containerPosition${id}`]);
986 const prevItemKeyRef = React.useRef(void 0);
987 let shouldSkipTransitionForRecycleReuse = false;
988- if (recycleItems && layoutTransition) {
989+ if (layoutTransition) {
990 const itemKeySignal = `containerItemKey${id}`;
991 const itemKey = peek$(ctx, itemKeySignal);
992 shouldSkipTransitionForRecycleReuse = itemKey !== void 0 && prevItemKeyRef.current !== void 0 && prevItemKeyRef.current !== itemKey;
993@@ -106,10 +106,20 @@ var ReanimatedPositionView = typedMemo(function ReanimatedPositionViewComponent(
994 () => [style, horizontal ? { left: positionValue } : { top: positionValue }],
995 [horizontal, positionValue, style]
996 );
997+ // Two kinds of repositions must not animate: (1) MVCP size adjustments,
998+ // which are compensated by an equal contentOffset shift so the row should
999+ // not visibly move — animating turns the invisible correction into a
1000+ // lurch-and-settle; (2) any reposition while the user is actively
1001+ // scrolling, where rows shifting under the finger reads as jank. The
1002+ // transition exists to smooth at-rest shifts (streaming text, work-log
1003+ // folds), so gate it to at-rest moments.
1004+ const now = Date.now();
1005+ const isMVCPReposition = now - (ctx.state.lastMVCPAdjustTime || 0) < 300 ||
1006+ now - (ctx.state.lastNativeScrollTime || 0) < 300;
1007 return /* @__PURE__ */ React.createElement(
1008 Reanimated.View,
1009 {
1010- layout: shouldSkipTransitionForRecycleReuse ? void 0 : layoutTransition,
1011+ layout: shouldSkipTransitionForRecycleReuse || isMVCPReposition ? void 0 : layoutTransition,
1012 ref: refView,
1013 style: viewStyle,
1014 ...rest