Skip to content

Commit

Permalink
another code example tuned in the tracking geometry post
Browse files Browse the repository at this point in the history
  • Loading branch information
mecid committed Nov 10, 2024
1 parent a729179 commit aae71b1
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion _posts/2024-08-13-tracking-geometry-changes-in-swiftui.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,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 aae71b1

Please sign in to comment.