Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hlfcoding/anime
:film_strip: UIView animation from the Far East
https://github.com/hlfcoding/anime
animation ios swift
Last synced: about 1 month ago
JSON representation
:film_strip: UIView animation from the Far East
- Host: GitHub
- URL: https://github.com/hlfcoding/anime
- Owner: hlfcoding
- License: mit
- Created: 2017-05-12T16:16:30.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-12-27T09:48:45.000Z (about 6 years ago)
- Last Synced: 2024-12-13T14:38:52.185Z (2 months ago)
- Topics: animation, ios, swift
- Language: Swift
- Homepage:
- Size: 134 KB
- Stars: 2
- Watchers: 4
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Anime
[](http://cocoapods.org/pods/Anime)
[](http://cocoapods.org/pods/Anime)
[](http://cocoapods.org/pods/Anime)
[](https://codeclimate.com/github/hlfcoding/Anime)> :film_strip: UIView animation from the Far East.

## Example
```swift
let a = Animation(of: { view.frame.origin.x += 10 }, duration: 1)
let b = a.with(animations: { view.frame.origin.x -= 10 })
let timeline = AnimationTimeline(a, b, b, a).start() { (finished) in
guard finished else {
// ...
return
}
print("done")
}
// ...
timeline.needsToCancel = true
```Compare the above 10 lines with the below 30 lines:
```swift
var isCancelled = false
let handleCancelled = {
// ...
}
let a = { view.frame.origin.x += 10 }
let b = { view.frame.origin.x -= 10 }
let start = {
UIView.animate(withDuration: 1, animations: a) { _ in
if isCancelled {
handleCancelled()
return
}
UIView.animate(withDuration: 1, animations: b) { _ in
if isCancelled {
handleCancelled()
return
}
UIView.animate(withDuration: 1, animations: b) { _ in
if isCancelled {
handleCancelled()
return
}
UIView.animate(withDuration: 1, animations: a) { _ in
print("done")
}
}
}
}
}
start()
// ...
isCancelled = true
```Animations can also be configured more flexibly, and appended in-flight:
```swift
var z = b
z.animations = { /* ... */ }
z.type = .keyframed(options: [])
// ...
timeline.append(z)
```To run the example project, clone the repo, and run `pod install` from the Example directory first.
## Requirements
Swift 4+
## Installation
Anime is available through [CocoaPods](http://cocoapods.org). To install
it, simply add the following line to your Podfile:```ruby
pod "Anime"
```## Author
Peng Wang, [email protected]
## License
Anime is available under the MIT license. See the LICENSE file for more info.