Skip to content

Commit

Permalink
behavior change; based on experiments
Browse files Browse the repository at this point in the history
  • Loading branch information
Reed Es committed Mar 13, 2022
1 parent c9376f4 commit 7f03d2c
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions Sources/Sideways.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,21 @@ public struct Sideways<Content: View>: View {
@State private var contentWidth: CGFloat = 0

public var body: some View {
ScrollView(.horizontal, showsIndicators: showIndicators) {
content()
.frame(minWidth: minWidth)
.background(
GeometryReader { geo -> Color in
DispatchQueue.main.async {
contentWidth = geo.size.width
GeometryReader { geo in
ScrollView(.horizontal, showsIndicators: showIndicators) {
content()
.frame(minWidth: max(geo.size.width, minWidth))
.background(
GeometryReader { geo -> Color in
DispatchQueue.main.async {
contentWidth = geo.size.width
}
return Color.clear
}
return Color.clear
}
)
)
}
.frame(maxWidth: min(geo.size.width, contentWidth))
}
.frame(maxWidth: contentWidth)
}
}

Expand Down

0 comments on commit 7f03d2c

Please sign in to comment.