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
SwiftUIScrolllibrary to add to your projectDependencies
License
See the LICENSE file.
An expanded
ScrollViewState(Source)Represents the current state of a
ScrollView, including:ScrollViewProxyCGPoint(from the upper/left corner)ScrollViewis actively scrolling, including decelerationReceiving a
ScrollViewState(Source)A view similar to
ScrollViewReaderproviding not only theScrollViewProxybut also the scroll view’s current offset and scrolling state. UnlikeScrollViewReader, this view acts as aScrollViewitself with the content being rendered as the scroll view content.Example Usage
FeatheredScrollView(Source)A specialized
ScrollViewthat 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%).