Skip to content

Commit

Permalink
Merge pull request Esri#975 from Esri/df/apollo/972
Browse files Browse the repository at this point in the history
`Carousel` - Fix horizontal manual scroll on Catalyst
  • Loading branch information
dfeinzimer authored Nov 18, 2024
2 parents 0fbe895 + 68aedc1 commit 683bfe2
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions Sources/ArcGISToolkit/Utility/Carousel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ struct Carousel<Content: View>: View {
/// The content shown in the Carousel.
let content: (_: CGSize, _: (() -> Void)?) -> Content

/// The amount to offset the scroll indicator.
let scrollIndicatorOffset = 10.0

/// This number is used to compute the final width that allows for a partially visible cell.
var cellBaseWidth = 120.0

Expand Down Expand Up @@ -55,7 +58,6 @@ struct Carousel<Content: View>: View {
ScrollViewReader { scrollViewProxy in
ScrollView(.horizontal) {
makeCommonScrollViewContent(scrollViewProxy)
.padding(.bottom, 10)
}
}
.onAppear {
Expand All @@ -66,15 +68,14 @@ struct Carousel<Content: View>: View {
}
}
// When a GeometryReader is within a List, height must be specified.
.frame(height: cellSize.height)
.frame(height: cellSize.height + scrollIndicatorOffset)
}

@available(iOS 18.0, *)
var iOS18Implementation: some View {
ScrollViewReader { scrollViewProxy in
ScrollView(.horizontal) {
makeCommonScrollViewContent(scrollViewProxy)
.padding(.bottom, 10)
}
}
.onScrollGeometryChange(for: CGFloat.self) { geometry in
Expand All @@ -94,6 +95,9 @@ struct Carousel<Content: View>: View {
.id(contentIdentifier)
.frame(width: cellSize.width, height: cellSize.height)
.clipped()
// Pad the content such that the scroll indicator appears beneath it
// so that the content is not covered.
.padding(.bottom, scrollIndicatorOffset)
}
}
}
Expand Down

0 comments on commit 683bfe2

Please sign in to comment.