Skip to content

Commit

Permalink
Merge pull request #65 from mecid/swift-testing-traits
Browse files Browse the repository at this point in the history
Swift testing traits
  • Loading branch information
mecid authored Nov 10, 2024
2 parents 909a237 + aae71b1 commit d0eb61d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions _posts/2024-08-13-tracking-geometry-changes-in-swiftui.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,14 @@ struct ContentView: View {
Color.clear
.frame(height: 0)
.onGeometryChange(for: CGFloat.self) { geometry in
return geometry.frame(in: .scrollView).minY
return geometry.frame(in: .named("scrollView")).minY
} action: { newValue in
offset = newValue
}

// Scroll content here...
}
.coordinateSpace(name: "scrollView")
.onChange(of: offset) {
print(offset)
}
Expand All @@ -79,13 +80,14 @@ struct ContentView: View {
Color.clear
.frame(height: 0)
.onGeometryChange(for: CGFloat.self) { geometry in
return geometry.frame(in: .scrollView).minY
return geometry.frame(in: .named("scrollView")).minY
} action: { old, new in
offset = min(old, new)
}

// Scroll content here...
}
.coordinateSpace(name: "scrollView")
.onChange(of: offset) {
print(offset)
}
Expand Down

0 comments on commit d0eb61d

Please sign in to comment.