Skip to content

Commit 91a1d51

Browse files
committed
first commit
1 parent 12e5a24 commit 91a1d51

File tree

19 files changed

+1370
-1
lines changed

19 files changed

+1370
-1
lines changed

Markdown/Scroller.gif

6.71 MB
Loading

Package.swift

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// swift-tools-version:5.5
2+
// The swift-tools-version declares the minimum version of Swift required to build this package.
3+
4+
import PackageDescription
5+
6+
let package = Package(
7+
name: "Scroller",
8+
platforms: [
9+
.iOS(.v14),
10+
.macOS(.v11)
11+
],
12+
products: [
13+
// Products define the executables and libraries a package produces, and make them visible to other packages.
14+
.library(
15+
name: "Scroller",
16+
targets: ["Scroller"]),
17+
],
18+
dependencies: [
19+
// Dependencies declare other packages that this package depends on.
20+
// .package(url: /* package url */, from: "1.0.0"),
21+
],
22+
targets: [
23+
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
24+
// Targets can depend on other targets in this package, and on products in packages this package depends on.
25+
.target(
26+
name: "Scroller",
27+
dependencies: []),
28+
.testTarget(
29+
name: "ScrollerTests",
30+
dependencies: ["Scroller"]),
31+
]
32+
)

README.md

+58-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,58 @@
1-
# Scroller
1+
# **Scroller**
2+
You can animate in individual views based on scroll position. Developed with SwiftUI. This library supports iOS/macOS.
3+
4+
[![Platforms](https://img.shields.io/badge/Platforms-iOS%20%7C%20macOS-blue?style=flat-square)](https://developer.apple.com/macOS)
5+
[![iOS](https://img.shields.io/badge/iOS-14.0-blue.svg)](https://developer.apple.com/iOS)
6+
[![macOS](https://img.shields.io/badge/macOS-11.0-blue.svg)](https://developer.apple.com/macOS)
7+
[![instagram](https://img.shields.io/badge/[email protected]?style=flat-square)](https://www.instagram.com/dev.fabula)
8+
[![SPM](https://img.shields.io/badge/SPM-compatible-red?style=flat-square)](https://developer.apple.com/documentation/swift_packages/package/)
9+
[![MIT](https://img.shields.io/badge/licenses-MIT-red.svg)](https://opensource.org/licenses/MIT)
10+
11+
## Screenshot
12+
<img src="Markdown/Scroller.gif">
13+
14+
## Usages
15+
1. Scroller
16+
```swift
17+
Scroller(.vertical, value: $valueV) {
18+
ForEach(0...5, id: \.self) { index in
19+
GeometryReader { proxy in
20+
ScrollerVContent(value: proxy.scrollerValue(.vertical))
21+
}
22+
}
23+
} lastContent: {
24+
Rectangle()
25+
.fill(Color.blue)
26+
.overlay(Text("LastView"))
27+
.foregroundColor(Color.white)
28+
}
29+
```
30+
31+
32+
3. Each view only needs to conform to the ScrollerContent protocol.
33+
```swift
34+
struct ScrollerVContent: ScrollerContent {
35+
36+
/// Bind each view's scroll-relative value. It is a value between 0 and 1.
37+
var value: CGFloat = 0
38+
39+
var body: some View {
40+
GeometryReader { proxy in
41+
ScrollerInfoView(axes: .vertical, value: value, proxy: proxy)
42+
.offset(y: proxy.size.height * value)
43+
.padding(10)
44+
Rectangle().fill(Color.blue)
45+
.frame(width: proxy.size.width * value, height: 5)
46+
.offset(y: proxy.size.height * value)
47+
}
48+
.background(Color.orange.opacity(1.0 - value))
49+
}
50+
}
51+
```
52+
53+
## Contact
54+
instagram : [@dev.fabula](https://www.instagram.com/dev.fabula)
55+
email : [dev.fabula@gmail.com](mailto:dev.fabula@gmail.com)
56+
57+
## License
58+
Scroller is available under the MIT license. See the [LICENSE](LICENSE) file for more info.

0 commit comments

Comments
 (0)