-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
1,370 additions
and
1 deletion.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"]), | ||
] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
|
||
[](https://developer.apple.com/macOS) | ||
[](https://developer.apple.com/iOS) | ||
[](https://developer.apple.com/macOS) | ||
[](https://www.instagram.com/dev.fabula) | ||
[](https://developer.apple.com/documentation/swift_packages/package/) | ||
[](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. |
Oops, something went wrong.