A view similar to ScrollViewReader providing not only the ScrollViewProxy but also the scroll view’s current offset and scrolling state. Unlike ScrollViewReader, this view acts as a ScrollView itself with the content being rendered as the scroll view content.
Example Usage
struct FooView : View {
var body : some View {
ScrollViewWithFeedback { state in
ForEach(0...100, id: \.self) { index in
Text("Item: \(index)")
}
.onChange(of: state.scrollOffset) { position in
print("OFFSET: \(position)")
}
}
}
}
struct FeatheredScrollView<Content : View> : View {
init(
maxFeatheredPercent: CGFloat = 0.05,
@ViewBuilder content: @escaping (ScrollViewState) -> Content
)
var body: some View { get }
}
A specialized ScrollView that applies a feathered mask to its content as the user begins to scroll upwards. The maximum amount of feathering is limited to requested % of the view’s height (defaults at 5%).
SwiftUIScroll Library
An open source library that provides extensions to SwiftUI libraries that help with scroll views.
Developed as re-usable components for various projects at XII’s iOS, macOS, and watchOS applications.
Installation
Swift Package Manager
SwiftUIScroll
library to add to your projectDependencies
License
See the LICENSE file.
An expanded
ScrollViewState
(Source)Represents the current state of a
ScrollView
, including:ScrollViewProxy
CGPoint
(from the upper/left corner)ScrollView
is actively scrolling, including decelerationReceiving a
ScrollViewState
(Source)A view similar to
ScrollViewReader
providing not only theScrollViewProxy
but also the scroll view’s current offset and scrolling state. UnlikeScrollViewReader
, this view acts as aScrollView
itself with the content being rendered as the scroll view content.Example Usage
FeatheredScrollView
(Source)A specialized
ScrollView
that applies a feathered mask to its content as the user begins to scroll upwards. The maximum amount of feathering is limited to requested % of the view’s height (defaults at 5%).