Skip to content

Commit

Permalink
removed coordinate system transformation since it shouldn't have an i…
Browse files Browse the repository at this point in the history
…nfluence on the height
  • Loading branch information
dkk committed Nov 26, 2022
1 parent b885066 commit dbd65bd
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Sources/WrappingHStack/WrappingHStack.swift
Expand Up @@ -10,7 +10,7 @@ import SwiftUI
/// between items and from the items to the border.) and lineSpacing (which
/// adds a vertical separation between lines)
public struct WrappingHStack: View {
private struct CGFloatPreferenceKey: PreferenceKey {
private struct HeightPreferenceKey: PreferenceKey {
static var defaultValue = CGFloat.zero
static func reduce(value: inout CGFloat , nextValue: () -> CGFloat) {
value = nextValue()
Expand Down Expand Up @@ -53,22 +53,22 @@ public struct WrappingHStack: View {
public var body: some View {
GeometryReader { geo in
InternalWrappingHStack (
width: geo.frame(in: .global).width,
width: geo.size.width,
alignment: alignment,
spacing: spacing,
lineSpacing: lineSpacing,
content: items
)
.anchorPreference(
key: CGFloatPreferenceKey.self,
key: HeightPreferenceKey.self,
value: .bounds,
transform: {
geo[$0].size.height
}
)
}
.frame(height: height)
.onPreferenceChange(CGFloatPreferenceKey.self, perform: {
.onPreferenceChange(HeightPreferenceKey.self, perform: {
if abs(height - $0) > 1 {
height = $0
}
Expand Down

0 comments on commit dbd65bd

Please sign in to comment.