Swiftpack.co - jasudev/Scroller as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by jasudev.
jasudev/Scroller 0.5.0
You can animate in individual views based on scroll position. Developed with SwiftUI. This library supports iOS/macOS.
⭐️ 39
🕓 2 years ago
iOS macOS
.package(url: "https://github.com/jasudev/Scroller.git", from: "0.5.0")

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.

GitHub

link
Stars: 39
Last commit: 1 year ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Release Notes

0.5.0
2 years ago

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics