Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jasudev committed Feb 2, 2022
1 parent 12e5a24 commit 91a1d51
Show file tree
Hide file tree
Showing 19 changed files with 1,370 additions and 1 deletion.
Binary file added Markdown/Scroller.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 32 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// swift-tools-version:5.5
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "Scroller",
platforms: [
.iOS(.v14),
.macOS(.v11)
],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(
name: "Scroller",
targets: ["Scroller"]),
],
dependencies: [
// Dependencies declare other packages that this package depends on.
// .package(url: /* package url */, from: "1.0.0"),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages this package depends on.
.target(
name: "Scroller",
dependencies: []),
.testTarget(
name: "ScrollerTests",
dependencies: ["Scroller"]),
]
)
59 changes: 58 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,58 @@
# Scroller
# **Scroller**
You can animate in individual views based on scroll position. Developed with SwiftUI. This library supports iOS/macOS.

[![Platforms](https://img.shields.io/badge/Platforms-iOS%20%7C%20macOS-blue?style=flat-square)](https://developer.apple.com/macOS)
[![iOS](https://img.shields.io/badge/iOS-14.0-blue.svg)](https://developer.apple.com/iOS)
[![macOS](https://img.shields.io/badge/macOS-11.0-blue.svg)](https://developer.apple.com/macOS)
[![instagram](https://img.shields.io/badge/instagram-@dev.fabula-orange.svg?style=flat-square)](https://www.instagram.com/dev.fabula)
[![SPM](https://img.shields.io/badge/SPM-compatible-red?style=flat-square)](https://developer.apple.com/documentation/swift_packages/package/)
[![MIT](https://img.shields.io/badge/licenses-MIT-red.svg)](https://opensource.org/licenses/MIT)

## Screenshot
<img src="Markdown/Scroller.gif">

## Usages
1. Scroller
```swift
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)
}
```


3. Each view only needs to conform to the ScrollerContent protocol.
```swift
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))
}
}
```

## Contact
instagram : [@dev.fabula](https://www.instagram.com/dev.fabula)
email : [dev.fabula@gmail.com](mailto:dev.fabula@gmail.com)

## License
Scroller is available under the MIT license. See the [LICENSE](LICENSE) file for more info.
Loading

0 comments on commit 91a1d51

Please sign in to comment.