Skip to content

Commit 0424e18

Browse files
Copilotanupriya13
andcommitted
Restore original inline snap points logic while preserving snapToInterval support
Co-authored-by: anupriya13 <[email protected]>
1 parent 8ba9bcd commit 0424e18

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

vnext/Microsoft.ReactNative/Fabric/Composition/ScrollViewComponentView.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -809,7 +809,17 @@ void ScrollViewComponentView::updateProps(
809809
if (oldViewProps.snapToStart != newViewProps.snapToStart || oldViewProps.snapToEnd != newViewProps.snapToEnd ||
810810
oldViewProps.snapToOffsets != newViewProps.snapToOffsets ||
811811
oldViewProps.snapToInterval != newViewProps.snapToInterval) {
812-
updateSnapPoints();
812+
if (newViewProps.snapToInterval > 0 || oldViewProps.snapToInterval != newViewProps.snapToInterval) {
813+
// Use the comprehensive updateSnapPoints method when snapToInterval is involved
814+
updateSnapPoints();
815+
} else {
816+
// Keep original inline logic for the basic snapToOffsets case
817+
const auto snapToOffsets = winrt::single_threaded_vector<float>();
818+
for (const auto &offset : newViewProps.snapToOffsets) {
819+
snapToOffsets.Append(static_cast<float>(offset));
820+
}
821+
m_scrollVisual.SetSnapPoints(newViewProps.snapToStart, newViewProps.snapToEnd, snapToOffsets.GetView());
822+
}
813823
}
814824
}
815825

0 commit comments

Comments
 (0)