Giter Site home page Giter Site logo

jasudev / scroller Goto Github PK

View Code? Open in Web Editor NEW
40.0 4.0 3.0 70.87 MB

You can animate in individual views based on scroll position. Developed with SwiftUI. This library supports iOS/macOS.

License: MIT License

Swift 100.00%
swiftui scroll scrolling scrollview animation animations scrollable swift scroll-animation scroll-animations

scroller's Introduction

Scroller for SwiftUI

You can animate in individual views based on scroll position. Developed with SwiftUI. This library supports iOS/macOS.

Platforms iOS macOS instagram SPM MIT

Screenshot

Example Vertical Horizontal

Example

https://fabulaapp.page.link/222
https://fabulaapp.page.link/223

Usages

  1. Scroller

    Scroller(.vertical, value: $valueV) {
        ForEach(0...5, id: \.self) { index in
            GeometryReader { proxy in
                ScrollerVContent(value: proxy.scrollerValue(.vertical))
            }
        }
    } lastContent: {
        Rectangle()
            .fill(Color.blue)
            .overlay(Text("LastView"))
            .foregroundColor(Color.white)
    }
  2. Each view only needs to conform to the ScrollerContent protocol.

    struct ScrollerVContent: ScrollerContent {
    
        /// Bind each view's scroll-relative value. It is a value between 0 and 1.
        var value: CGFloat = 0
        
        var body: some View {
            GeometryReader { proxy in
                ScrollerInfoView(axes: .vertical, value: value, proxy: proxy)
                    .offset(y: proxy.size.height * value)
                    .padding(10)
                Rectangle().fill(Color.blue)
                    .frame(width: proxy.size.width * value, height: 5)
                    .offset(y: proxy.size.height * value)
            }
            .background(Color.orange.opacity(1.0 - value))
        }
    }

Swift Package Manager

The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift compiler. Once you have your Swift package set up, adding Scroller as a dependency is as easy as adding it to the dependencies value of your Package.swift.

dependencies: [
    .package(url: "https://github.com/jasudev/Scroller.git", .branch("main"))
]

Contact

instagram : @dev.fabula
email : [email protected]

License

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

scroller's People

Contributors

adamnemecek avatar jasudev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  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.