From a729179af0edce4db2af27de991212e210260be4 Mon Sep 17 00:00:00 2001 From: Majid Jabrayilov Date: Mon, 11 Nov 2024 00:59:53 +0400 Subject: [PATCH 1/2] geometry tracking post code example updated --- _posts/2024-08-13-tracking-geometry-changes-in-swiftui.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/_posts/2024-08-13-tracking-geometry-changes-in-swiftui.md b/_posts/2024-08-13-tracking-geometry-changes-in-swiftui.md index 856e09bd..782b2acf 100644 --- a/_posts/2024-08-13-tracking-geometry-changes-in-swiftui.md +++ b/_posts/2024-08-13-tracking-geometry-changes-in-swiftui.md @@ -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) } From aae71b1cd66748577050969627df636fca4ccf14 Mon Sep 17 00:00:00 2001 From: Majid Jabrayilov Date: Mon, 11 Nov 2024 01:02:32 +0400 Subject: [PATCH 2/2] another code example tuned in the tracking geometry post --- _posts/2024-08-13-tracking-geometry-changes-in-swiftui.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/_posts/2024-08-13-tracking-geometry-changes-in-swiftui.md b/_posts/2024-08-13-tracking-geometry-changes-in-swiftui.md index 782b2acf..27801c22 100644 --- a/_posts/2024-08-13-tracking-geometry-changes-in-swiftui.md +++ b/_posts/2024-08-13-tracking-geometry-changes-in-swiftui.md @@ -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) }