Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alikaragoz/DaisyChain
:link: Easy animation chaining
https://github.com/alikaragoz/DaisyChain
Last synced: 3 months ago
JSON representation
:link: Easy animation chaining
- Host: GitHub
- URL: https://github.com/alikaragoz/DaisyChain
- Owner: alikaragoz
- License: mit
- Archived: true
- Created: 2015-12-15T00:32:36.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-10-04T15:41:22.000Z (about 7 years ago)
- Last Synced: 2024-04-24T14:46:53.011Z (6 months ago)
- Language: Swift
- Homepage:
- Size: 27.3 KB
- Stars: 31
- Watchers: 3
- Forks: 6
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-ios - DaisyChain - Easy animation chaining. (UI / Animation)
- awesome-ios-star - DaisyChain - Easy animation chaining. (UI / Animation)
README
[![Build Status](https://travis-ci.org/alikaragoz/DaisyChain.svg?branch=master)](https://travis-ci.org/alikaragoz/DaisyChain)
[![Version](http://img.shields.io/cocoapods/v/DaisyChain.svg)](http://cocoapods.org/?q=DaisyChain)
[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)DaisyChain
----------**DaisyChain** is a micro framework which makes UIView animations chaining dead simple. It uses the exact same interface you are familiars with.
#### Chaining made simple
We all have seen or written code which looks like this:```swift
UIView.animateWithDuration(0.5, animations: {
view.center = CGPointMake(0.0, 0.0)
}) { _ in
UIView.animateWithDuration(0.5, animations: {
view.center = CGPointMake(100.0, 0.0)
}) { _ in
UIView.animateWithDuration(0.5, animations: {
view.center = CGPointMake(100.0, 100.0)
}) { _ in
UIView.animateWithDuration(0.5, animations: {
view.center = CGPointMake(0.0, 100.0)
}) { _ in
UIView.animateWithDuration(0.5, animations: {
view.center = CGPointMake(0.0, 0.0)
})
}
}
}
}
```This can go pretty far, it is also know as the *callback hell*. It's not very flexible and hard to read.
With **DaisyChain** the above code looks like this:
```swift
let chain = DaisyChain()chain.animateWithDuration(0.5, animations: {
view.center = CGPointMake(0.0, 0.0)
})chain.animateWithDuration(0.5, animations: {
view.center = CGPointMake(100.0, 0.0)
})chain.animateWithDuration(0.5, animations: {
view.center = CGPointMake(100.0, 100.0)
})chain.animateWithDuration(0.5, animations: {
view.center = CGPointMake(0.0, 100.0)
})chain.animateWithDuration(0.5, animations: {
view.center = CGPointMake(0.0, 0.0)
})
```As you can the the code looks more flat, it allows you to easy modify orders or add new steps.
#### Breakable chains
**DaisyChain** also adds a simple way to break animation sequences, simply set the `broken` property to `yes` to break a chain:
```swift
chain.broken = true
```To continue chaining animation, you'll need to put it back to `false` or create a new chain.
#### Setting up with CocoaPods
```ruby
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!pod 'DaisyChain', '~> 1.0.0'
```#### Setting up with Carthage
```ogdl
github "alikaragoz/DaisyChain" ~> 1.0.0
```#### License
DaisyChain is available under the [MIT license](https://github.com/alikaragoz/DaisyChain/blob/master/LICENSE).