@@ -10,12 +10,14 @@ public struct HStackSnapCore<Content: View>: View {
1010
1111 public init (
1212 leadingOffset: CGFloat ,
13+ spacing: CGFloat ? = nil ,
1314 coordinateSpace: String = " SnapToScroll " ,
1415 @ViewBuilder content: @escaping ( ) -> Content ,
1516 eventHandler: SnapToScrollEventHandler ? = . none) {
1617
1718 self . content = content
1819 self . targetOffset = leadingOffset
20+ self . spacing = spacing
1921 self . scrollOffset = leadingOffset
2022 self . coordinateSpace = coordinateSpace
2123 self . eventHandler = eventHandler
@@ -27,7 +29,7 @@ public struct HStackSnapCore<Content: View>: View {
2729 GeometryReader { geometry in
2830
2931 HStack {
30- HStack ( content: content)
32+ HStack ( spacing : spacing , content: content)
3133 . offset ( x: scrollOffset, y: . zero)
3234 . animation ( . easeOut( duration: 0.2 ) )
3335
@@ -145,6 +147,9 @@ public struct HStackSnapCore<Content: View>: View {
145147 /// Calculated offset based on `SnapLocation`
146148 @State private var targetOffset : CGFloat
147149
150+ /// Space between content views`
151+ @State private var spacing : CGFloat ?
152+
148153 /// The original offset of each frame, used to calculate `scrollOffset`
149154 @State private var snapLocations : [ Int : CGFloat ] = [ : ]
150155
0 commit comments