Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/danielsaidi/scrollkit
ScrollKit is a SwiftUI SDK that adds powerful scroll features, like offset tracking and a header view that stretches & transforms as you pull down, and sticks to the top when you scroll.
https://github.com/danielsaidi/scrollkit
ios macos scrollview sticky-header swiftui tvos visionos watchos
Last synced: 4 days ago
JSON representation
ScrollKit is a SwiftUI SDK that adds powerful scroll features, like offset tracking and a header view that stretches & transforms as you pull down, and sticks to the top when you scroll.
- Host: GitHub
- URL: https://github.com/danielsaidi/scrollkit
- Owner: danielsaidi
- License: mit
- Created: 2023-02-04T13:24:58.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-10-05T09:40:50.000Z (4 months ago)
- Last Synced: 2025-01-10T23:06:41.567Z (11 days ago)
- Topics: ios, macos, scrollview, sticky-header, swiftui, tvos, visionos, watchos
- Language: Swift
- Homepage:
- Size: 13.1 MB
- Stars: 741
- Watchers: 5
- Forks: 26
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
## About ScrollKit
ScrollKit is a SwiftUI SDK that adds powerful scroll features, like offset tracking and a header view that stretches & transforms as you pull down, and sticks to the top when you scroll.
ScrollKit works on all major Apple platforms and is designed to be easy to use. It current doesn't use the new `ScrollView` APIs for OS backwards compatibility reasons, but will eventually do so.
## Installation
ScrollKit can be installed with the Swift Package Manager:
```
https://github.com/danielsaidi/ScrollKit.git
```## Getting started
ScrollKit has a `ScrollViewWithOffsetTracking` view that can detect scrolling:
```swift
ScrollViewWithOffsetTracking { offset in
print(offset)
} content: {
// Add your scroll content here, e.g. a `LazyVStack`
}
```ScrollKit also has a `ScrollViewWithStickyHeader` that makes it easy to set up a stretchy, sticky header:
```swift
struct MyView: View {@State
private var offset = CGPoint.zero
@State
private var visibleRatio = CGFloat.zero
func handleOffset(_ scrollOffset: CGPoint, visibleHeaderRatio: CGFloat) {
self.offset = scrollOffset
self.visibleRatio = visibleHeaderRatio
}
func header() -> some View {
ZStack(alignment: .bottomLeading) {
Color.blue
Color.yellow.opacity(visibleRatio) // Fades in
}
}var body: some View {
ScrollViewWithStickyHeader(
header: header,
headerHeight: 250,
headerMinHeight: 150,
onScroll: handleOffset
) {
// Add your scroll content here, e.g. a `LazyVStack`
}
}
}
```For more information, please see the [getting started guide][Getting-Started].
## Documentation
The [online documentation][Documentation] has more information, articles, code examples, etc.
## Demo Application
The demo app lets you explore the library. To try it out, just open and run the `Demo` project.
## Support my work
You can [sponsor me][Sponsors] on GitHub Sponsors or [reach out][Email] for paid support, to help support my [open-source projects][OpenSource].
Your support makes it possible for me to put more work into these projects and make them the best they can be.
## Contact
Feel free to reach out if you have questions or want to contribute in any way:
* Website: [danielsaidi.com][Website]
* Mastodon: [@[email protected]][Mastodon]
* Twitter: [@danielsaidi][Twitter]
* E-mail: [[email protected]][Email]## License
ScrollKit is available under the MIT license. See the [LICENSE][License] file for more info.
[Email]: mailto:[email protected]
[Website]: https://danielsaidi.com
[GitHub]: https://github.com/danielsaidi
[Twitter]: https://twitter.com/danielsaidi
[Mastodon]: https://mastodon.social/@danielsaidi
[OpenSource]: https://danielsaidi.com/opensource
[Sponsors]: https://github.com/sponsors/danielsaidi[Documentation]: https://danielsaidi.github.io/ScrollKit/
[Getting-Started]: https://danielsaidi.github.io/ScrollKit/documentation/scrollkit/getting-started[License]: https://github.com/danielsaidi/ScrollKit/blob/master/LICENSE