Skip to content

Commit 683bfe2

Browse files
authored
Merge pull request #975 from Esri/df/apollo/972
`Carousel` - Fix horizontal manual scroll on Catalyst
2 parents 0fbe895 + 68aedc1 commit 683bfe2

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

Diff for: Sources/ArcGISToolkit/Utility/Carousel.swift

+7-3
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ struct Carousel<Content: View>: View {
2727
/// The content shown in the Carousel.
2828
let content: (_: CGSize, _: (() -> Void)?) -> Content
2929

30+
/// The amount to offset the scroll indicator.
31+
let scrollIndicatorOffset = 10.0
32+
3033
/// This number is used to compute the final width that allows for a partially visible cell.
3134
var cellBaseWidth = 120.0
3235

@@ -55,7 +58,6 @@ struct Carousel<Content: View>: View {
5558
ScrollViewReader { scrollViewProxy in
5659
ScrollView(.horizontal) {
5760
makeCommonScrollViewContent(scrollViewProxy)
58-
.padding(.bottom, 10)
5961
}
6062
}
6163
.onAppear {
@@ -66,15 +68,14 @@ struct Carousel<Content: View>: View {
6668
}
6769
}
6870
// When a GeometryReader is within a List, height must be specified.
69-
.frame(height: cellSize.height)
71+
.frame(height: cellSize.height + scrollIndicatorOffset)
7072
}
7173

7274
@available(iOS 18.0, *)
7375
var iOS18Implementation: some View {
7476
ScrollViewReader { scrollViewProxy in
7577
ScrollView(.horizontal) {
7678
makeCommonScrollViewContent(scrollViewProxy)
77-
.padding(.bottom, 10)
7879
}
7980
}
8081
.onScrollGeometryChange(for: CGFloat.self) { geometry in
@@ -94,6 +95,9 @@ struct Carousel<Content: View>: View {
9495
.id(contentIdentifier)
9596
.frame(width: cellSize.width, height: cellSize.height)
9697
.clipped()
98+
// Pad the content such that the scroll indicator appears beneath it
99+
// so that the content is not covered.
100+
.padding(.bottom, scrollIndicatorOffset)
97101
}
98102
}
99103
}

0 commit comments

Comments
 (0)