Giter Site home page Giter Site logo

dongminlim / scrollkit Goto Github PK

View Code? Open in Web Editor NEW

This project forked from danielsaidi/scrollkit

0.0 0.0 0.0 11.2 MB

ScrollKit is a SwiftUI library that adds powerful scrolling features to SwiftUI, such as offset tracking and sticky scroll view headers.

License: MIT License

Ruby 16.29% Swift 83.71%

scrollkit's Introduction

ScrollKit Logo

Version Swift 5.7 Swift UI MIT License Twitter: @danielsaidi Mastodon: @danielsaidi@mastodon.social

About ScrollKit

ScrollKit is a SwiftUI library that adds powerful scrolling features to SwiftUI, such as scroll offset tracking and scroll view headers that stretch out as you pull down and stick to the top when you scroll.

The result can look like this, or completely different:

The views in this library are designed to be easy to use, and basically just add more properties to the standard SwiftUI ScrollView. They can be used on all Apple platforms, including iOS, macOS, tvOS and watchOS.

Installation

ScrollKit can be installed with the Swift Package Manager:

https://github.com/danielsaidi/ScrollKit.git

or with CocoaPods:

pod DSScrollKit

If you prefer to not have external dependencies, you can also just copy the source code into your app.

Supported Platforms

ScrollKit supports iOS 14, macOS 11, tvOS 14 and watchOS 7.

Getting started

The online documentation has a getting started guide guide to help you get started with ScrollKit.

To create a scroll view with a stretchable, sticky header, just create a ScrollViewWithStickyHeader and provide it with a header view and header height:

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.visible = 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,
            onScroll: handleOffset
        ) {
            // Add your scroll view content here as regular
        }
    }
}

The header visible ratio is based on the header height and scroll view offset and lets you adjust your content as the header is scrolled under the navigation bar, for instance to modify the header and fade in a navigation title.

For more information, please see the online documentation and getting started guide guide.

Documentation

The online documentation contains more information, code examples, etc., and makes it easy to overview the various parts of the library.

Demo Application

The demo app lets you explore the library on iOS and macOS. To try it out, just open and run the Demo project.

Support

You can sponsor this project on GitHub Sponsors or get in touch for paid support.

Contact

Feel free to reach out if you have questions or if you want to contribute in any way:

License

ScrollKit is available under the MIT license. See the LICENSE file for more info.

scrollkit's People

Contributors

danielsaidi avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.