@@ -204,7 +204,7 @@ index 8204015..cdeaab7 100644
204204 * Number of columns to render items in.
205205 * @default 1
206206diff --git a/react-native.js b/react-native.js
207- index 229f09a..5250db2 100644
207+ index 229f09a..2a1ceb6 100644
208208--- a/react-native.js
209209+++ b/react-native.js
210210@@ -930,7 +930,7 @@ function setInitialRenderState(ctx, {
@@ -309,7 +309,18 @@ index 229f09a..5250db2 100644
309309 }
310310 setTimeout(
311311 () => {
312- @@ -1674,7 +1700,9 @@ function getPredictedNativeClamp(state, unresolvedAmount, totalSize) {
312+ @@ -1571,6 +1597,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+ @@ -1674,7 +1704,9 @@ function getPredictedNativeClamp(state, unresolvedAmount, totalSize) {
313324 if (Math.abs(unresolvedAmount) <= MVCP_POSITION_EPSILON) {
314325 return 0;
315326 }
@@ -320,7 +331,7 @@ index 229f09a..5250db2 100644
320331 const clampDelta = maxScroll - state.scroll;
321332 if (unresolvedAmount < 0) {
322333 return Math.max(unresolvedAmount, Math.min(0, clampDelta));
323- @@ -1736,7 +1764 ,7 @@ function resolvePendingNativeMVCPAdjust(ctx, newScroll) {
334+ @@ -1736,7 +1768 ,7 @@ function resolvePendingNativeMVCPAdjust(ctx, newScroll) {
324335 settlePendingNativeMVCPAdjust(ctx, remainingAfterManual, nativeDelta);
325336 return true;
326337 }
@@ -329,7 +340,7 @@ index 229f09a..5250db2 100644
329340 const distanceToClamp = Math.abs(newScroll - expectedNativeClampScroll);
330341 const isAtExpectedNativeClamp = distanceToClamp <= NATIVE_END_CLAMP_EPSILON;
331342 if (isAtExpectedNativeClamp) {
332- @@ -1869,7 +1897 ,7 @@ function prepareMVCP(ctx, dataChanged) {
343+ @@ -1869,7 +1901 ,7 @@ function prepareMVCP(ctx, dataChanged) {
333344 if (diff > 0) {
334345 diff = Math.max(0, totalSize - state.scroll - state.scrollLength);
335346 } else {
@@ -338,7 +349,7 @@ index 229f09a..5250db2 100644
338349 state.scroll = maxScroll;
339350 state.scrollPending = maxScroll;
340351 diff = 0;
341- @@ -2274,8 +2302 ,121 @@ function scrollToIndex(ctx, {
352+ @@ -2274,8 +2306 ,121 @@ function scrollToIndex(ctx, {
342353 }
343354
344355 // src/core/initialScroll.ts
@@ -460,7 +471,7 @@ index 229f09a..5250db2 100644
460471 const requestedIndex = target.index;
461472 const index = requestedIndex !== void 0 ? clampScrollIndex(requestedIndex, ctx.state.props.data.length) : void 0;
462473 const itemSize = getItemSizeAtIndex(ctx, index);
463- @@ -2704,7 +2845 ,9 @@ function clearFinishedBootstrapInitialScrollTargetIfMovedAway(ctx) {
474+ @@ -2704,7 +2849 ,9 @@ function clearFinishedBootstrapInitialScrollTargetIfMovedAway(ctx) {
464475 return;
465476 }
466477 if (didFinishedInitialScrollMoveAwayFromTarget(ctx, initialScroll)) {
@@ -471,7 +482,7 @@ index 229f09a..5250db2 100644
471482 if (!shouldKeepEndTargetAlive) {
472483 if (shouldPreserveInitialScrollForFooterLayout(initialScroll)) {
473484 clearPendingInitialScrollFooterLayout(ctx, {
474- @@ -4637,7 +4780 ,8 @@ function maybeUpdateAnchoredEndSpace(ctx) {
485+ @@ -4637,7 +4784 ,8 @@ function maybeUpdateAnchoredEndSpace(ctx) {
475486 }
476487 contentBelowAnchor += footerSize + stylePaddingBottom;
477488 isReady = !hasUnknownTailSize;
@@ -481,7 +492,7 @@ index 229f09a..5250db2 100644
481492 } else if (anchorIndex >= 0) {
482493 isReady = false;
483494 }
484- @@ -4655,6 +4799 ,12 @@ function maybeUpdateAnchoredEndSpace(ctx) {
495+ @@ -4655,6 +4803 ,12 @@ function maybeUpdateAnchoredEndSpace(ctx) {
485496 updateScroll(ctx, state.scroll, true);
486497 }
487498 (_b = anchoredEndSpace == null ? void 0 : anchoredEndSpace.onReady) == null ? void 0 : _b.call(anchoredEndSpace, { anchorIndex: nextAnchorIndex, anchorKey: nextAnchorKey, size: nextSize });
@@ -494,23 +505,23 @@ index 229f09a..5250db2 100644
494505 }
495506 return nextSize;
496507 }
497- @@ -6960,6 +7110 ,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
508+ @@ -6960,6 +7114 ,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
498509 dataVersion,
499510 drawDistance = 250,
500511 contentInsetEndAdjustment,
501512+ contentInsetStartAdjustment,
502513 estimatedItemSize = 100,
503514 estimatedListSize,
504515 extraData,
505- @@ -6990,6 +7141 ,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
516+ @@ -6990,6 +7145 ,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
506517 onLayout: onLayoutProp,
507518 onLoad,
508519 onMomentumScrollEnd,
509520+ onScrollBeginDrag,
510521 onRefresh,
511522 onScroll: onScrollProp,
512523 onScrollBeginDrag,
513- @@ -7076,7 +7228 ,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
524+ @@ -7076,7 +7232 ,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
514525 const combinedRef = useCombinedRef(refScroller, refScrollView);
515526 const keyExtractor = keyExtractorProp != null ? keyExtractorProp : ((_item, index) => index.toString());
516527 const stickyHeaderIndices = stickyHeaderIndicesProp;
@@ -519,15 +530,15 @@ index 229f09a..5250db2 100644
519530 const previousContentInsetEndAdjustmentRef = React2.useRef(contentInsetEndAdjustmentResolved);
520531 const alwaysRenderIndices = React2.useMemo(() => {
521532 const indices = getAlwaysRenderIndices(alwaysRender, dataProp, keyExtractor, anchoredEndSpace == null ? void 0 : anchoredEndSpace.anchorIndex);
522- @@ -7215,6 +7367 ,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
533+ @@ -7215,6 +7371 ,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
523534 contentContainerAlignItems: contentContainerStyle.alignItems,
524535 contentInset,
525536 contentInsetEndAdjustment: contentInsetEndAdjustmentResolved,
526537+ contentInsetStartAdjustment,
527538 data: dataProp,
528539 dataKey,
529540 dataVersion,
530- @@ -7303,6 +7456 ,13 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
541+ @@ -7303,6 +7460 ,13 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
531542 return void 0;
532543 }
533544 const resolvedOffset = (_a4 = initialScroll.contentOffset) != null ? _a4 : resolveInitialScrollOffset(ctx, initialScroll);
@@ -541,15 +552,15 @@ index 229f09a..5250db2 100644
541552 return usesBootstrapInitialScroll && ((_b2 = state.initialScrollSession) == null ? void 0 : _b2.kind) === "bootstrap" && Platform.OS === "web" ? void 0 : resolvedOffset;
542553 }, [usesBootstrapInitialScroll]);
543554 React2.useLayoutEffect(() => {
544- @@ -7526,6 +7686 ,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
555+ @@ -7526,6 +7690 ,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
545556 onScroll: (event) => onScroll(ctx, event),
546557 onScrollBeginDrag: (event) => {
547558 var _a4, _b2;
548559+ ctx.state.didUserDrag = true;
549560 prepareReachedEdgeForNextUserScroll(ctx);
550561 (_b2 = (_a4 = state.props).onScrollBeginDrag) == null ? void 0 : _b2.call(_a4, event);
551562 },
552- @@ -7555,6 +7716 ,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
563+ @@ -7555,6 +7720 ,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
553564 onLayout,
554565 onLayoutFooter,
555566 onMomentumScrollEnd: fns.onMomentumScrollEnd,
@@ -558,7 +569,7 @@ index 229f09a..5250db2 100644
558569 recycleItems,
559570 refreshControl: refreshControlElement ? stylePaddingTopState > 0 ? React2__namespace.cloneElement(refreshControlElement, {
560571diff --git a/react-native.mjs b/react-native.mjs
561- index c2e0f38..4ae8331 100644
572+ index c2e0f38..5313086 100644
562573--- a/react-native.mjs
563574+++ b/react-native.mjs
564575@@ -909,7 +909,7 @@ function setInitialRenderState(ctx, {
@@ -663,7 +674,18 @@ index c2e0f38..4ae8331 100644
663674 }
664675 setTimeout(
665676 () => {
666- @@ -1653,7 +1679,9 @@ function getPredictedNativeClamp(state, unresolvedAmount, totalSize) {
677+ @@ -1550,6 +1576,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+ @@ -1653,7 +1683,9 @@ function getPredictedNativeClamp(state, unresolvedAmount, totalSize) {
667689 if (Math.abs(unresolvedAmount) <= MVCP_POSITION_EPSILON) {
668690 return 0;
669691 }
@@ -674,7 +696,7 @@ index c2e0f38..4ae8331 100644
674696 const clampDelta = maxScroll - state.scroll;
675697 if (unresolvedAmount < 0) {
676698 return Math.max(unresolvedAmount, Math.min(0, clampDelta));
677- @@ -1715,7 +1743 ,7 @@ function resolvePendingNativeMVCPAdjust(ctx, newScroll) {
699+ @@ -1715,7 +1747 ,7 @@ function resolvePendingNativeMVCPAdjust(ctx, newScroll) {
678700 settlePendingNativeMVCPAdjust(ctx, remainingAfterManual, nativeDelta);
679701 return true;
680702 }
@@ -683,7 +705,7 @@ index c2e0f38..4ae8331 100644
683705 const distanceToClamp = Math.abs(newScroll - expectedNativeClampScroll);
684706 const isAtExpectedNativeClamp = distanceToClamp <= NATIVE_END_CLAMP_EPSILON;
685707 if (isAtExpectedNativeClamp) {
686- @@ -1848,7 +1876 ,7 @@ function prepareMVCP(ctx, dataChanged) {
708+ @@ -1848,7 +1880 ,7 @@ function prepareMVCP(ctx, dataChanged) {
687709 if (diff > 0) {
688710 diff = Math.max(0, totalSize - state.scroll - state.scrollLength);
689711 } else {
@@ -692,7 +714,7 @@ index c2e0f38..4ae8331 100644
692714 state.scroll = maxScroll;
693715 state.scrollPending = maxScroll;
694716 diff = 0;
695- @@ -2253,8 +2281 ,121 @@ function scrollToIndex(ctx, {
717+ @@ -2253,8 +2285 ,121 @@ function scrollToIndex(ctx, {
696718 }
697719
698720 // src/core/initialScroll.ts
@@ -814,7 +836,7 @@ index c2e0f38..4ae8331 100644
814836 const requestedIndex = target.index;
815837 const index = requestedIndex !== void 0 ? clampScrollIndex(requestedIndex, ctx.state.props.data.length) : void 0;
816838 const itemSize = getItemSizeAtIndex(ctx, index);
817- @@ -2683,7 +2824 ,9 @@ function clearFinishedBootstrapInitialScrollTargetIfMovedAway(ctx) {
839+ @@ -2683,7 +2828 ,9 @@ function clearFinishedBootstrapInitialScrollTargetIfMovedAway(ctx) {
818840 return;
819841 }
820842 if (didFinishedInitialScrollMoveAwayFromTarget(ctx, initialScroll)) {
@@ -825,7 +847,7 @@ index c2e0f38..4ae8331 100644
825847 if (!shouldKeepEndTargetAlive) {
826848 if (shouldPreserveInitialScrollForFooterLayout(initialScroll)) {
827849 clearPendingInitialScrollFooterLayout(ctx, {
828- @@ -4616,7 +4759 ,8 @@ function maybeUpdateAnchoredEndSpace(ctx) {
850+ @@ -4616,7 +4763 ,8 @@ function maybeUpdateAnchoredEndSpace(ctx) {
829851 }
830852 contentBelowAnchor += footerSize + stylePaddingBottom;
831853 isReady = !hasUnknownTailSize;
@@ -835,7 +857,7 @@ index c2e0f38..4ae8331 100644
835857 } else if (anchorIndex >= 0) {
836858 isReady = false;
837859 }
838- @@ -4634,6 +4778 ,12 @@ function maybeUpdateAnchoredEndSpace(ctx) {
860+ @@ -4634,6 +4782 ,12 @@ function maybeUpdateAnchoredEndSpace(ctx) {
839861 updateScroll(ctx, state.scroll, true);
840862 }
841863 (_b = anchoredEndSpace == null ? void 0 : anchoredEndSpace.onReady) == null ? void 0 : _b.call(anchoredEndSpace, { anchorIndex: nextAnchorIndex, anchorKey: nextAnchorKey, size: nextSize });
@@ -848,23 +870,15 @@ index c2e0f38..4ae8331 100644
848870 }
849871 return nextSize;
850872 }
851- @@ -6939,6 +7089 ,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
873+ @@ -6939,6 +7093 ,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
852874 dataVersion,
853875 drawDistance = 250,
854876 contentInsetEndAdjustment,
855877+ contentInsetStartAdjustment,
856878 estimatedItemSize = 100,
857879 estimatedListSize,
858880 extraData,
859- @@ -6969,6 +7120,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
860- onLayout: onLayoutProp,
861- onLoad,
862- onMomentumScrollEnd,
863- + onScrollBeginDrag,
864- onRefresh,
865- onScroll: onScrollProp,
866- onScrollBeginDrag,
867- @@ -7055,7 +7207,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
881+ @@ -7055,7 +7210,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
868882 const combinedRef = useCombinedRef(refScroller, refScrollView);
869883 const keyExtractor = keyExtractorProp != null ? keyExtractorProp : ((_item, index) => index.toString());
870884 const stickyHeaderIndices = stickyHeaderIndicesProp;
@@ -873,15 +887,15 @@ index c2e0f38..4ae8331 100644
873887 const previousContentInsetEndAdjustmentRef = useRef(contentInsetEndAdjustmentResolved);
874888 const alwaysRenderIndices = useMemo(() => {
875889 const indices = getAlwaysRenderIndices(alwaysRender, dataProp, keyExtractor, anchoredEndSpace == null ? void 0 : anchoredEndSpace.anchorIndex);
876- @@ -7194,6 +7346 ,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
890+ @@ -7194,6 +7349 ,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
877891 contentContainerAlignItems: contentContainerStyle.alignItems,
878892 contentInset,
879893 contentInsetEndAdjustment: contentInsetEndAdjustmentResolved,
880894+ contentInsetStartAdjustment,
881895 data: dataProp,
882896 dataKey,
883897 dataVersion,
884- @@ -7282,6 +7435 ,13 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
898+ @@ -7282,6 +7438 ,13 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
885899 return void 0;
886900 }
887901 const resolvedOffset = (_a4 = initialScroll.contentOffset) != null ? _a4 : resolveInitialScrollOffset(ctx, initialScroll);
@@ -895,15 +909,15 @@ index c2e0f38..4ae8331 100644
895909 return usesBootstrapInitialScroll && ((_b2 = state.initialScrollSession) == null ? void 0 : _b2.kind) === "bootstrap" && Platform.OS === "web" ? void 0 : resolvedOffset;
896910 }, [usesBootstrapInitialScroll]);
897911 useLayoutEffect(() => {
898- @@ -7505,6 +7665 ,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
912+ @@ -7505,6 +7668 ,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
899913 onScroll: (event) => onScroll(ctx, event),
900914 onScrollBeginDrag: (event) => {
901915 var _a4, _b2;
902916+ ctx.state.didUserDrag = true;
903917 prepareReachedEdgeForNextUserScroll(ctx);
904918 (_b2 = (_a4 = state.props).onScrollBeginDrag) == null ? void 0 : _b2.call(_a4, event);
905919 },
906- @@ -7534,6 +7695 ,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
920+ @@ -7534,6 +7698 ,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
907921 onLayout,
908922 onLayoutFooter,
909923 onMomentumScrollEnd: fns.onMomentumScrollEnd,
@@ -928,3 +942,73 @@ index 940da28..28dccbe 100644
928942 /**
929943 * Number of columns to render items in.
930944 * @default 1
945+ diff --git a/reanimated.js b/reanimated.js
946+ index f1265fa..16dcef0 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
980+ diff --git a/reanimated.mjs b/reanimated.mjs
981+ index 29a00d5..9c25ec5 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
0 commit comments