From 3522771f51d48bd631673bbdb5d104e59ba7a24e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Lign=C3=A9?= Date: Fri, 2 May 2025 09:23:43 +0200 Subject: [PATCH] Fix variable name in README.md example MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I also added the imports at the top so that you can copy the entire code block and paste it into Xcode to get going - let me know if I should remove that 😊 --- README.md | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 01837be..25dcb07 100644 --- a/README.md +++ b/README.md @@ -49,11 +49,14 @@ ScrollViewWithOffsetTracking { offset in ScrollKit has a `ScrollViewWithStickyHeader` that makes it easy to set up a stretchy, sticky header: ```swift +import SwiftUI +import ScrollKit + struct MyView: View { @State - private var offset = CGPoint.zero - + private var scrollOffset = CGPoint.zero + @State private var visibleRatio = CGFloat.zero @@ -63,7 +66,7 @@ struct MyView: View { headerHeight: 250, // The resting header height headerMinHeight: 150, // The minimum header height headerStretch: false, // Disables the stretch effect - contentCornerRadius: 20 // An optional corner radius mask + contentCornerRadius: 20, // An optional corner radius mask onScroll: handleScroll // An optional scroll handler action ) { // Add your scroll content here, e.g. a `LazyVStack` @@ -79,7 +82,7 @@ struct MyView: View { ZStack { Color.red ScrollViewHeaderGradient() // By default a dark gradient - Text("Scroll offset: \(offset.y)") + Text("Scroll offset: \(scrollOffset.y)") } } }