DaisyChain is a micro framework which makes UIView animations chaining dead simple.

Related tags

Animation DaisyChain
Overview

Build Status Version Carthage compatible

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:

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:

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:

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

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!

pod 'DaisyChain', '~> 1.0.0'

Setting up with Carthage

1.0.0 ">
github "alikaragoz/DaisyChain" ~> 1.0.0

License

DaisyChain is available under the MIT license.

You might also like...
Designed for gesture-driven animations. Fast, simple, & extensible!
Designed for gesture-driven animations. Fast, simple, & extensible!

Yet Another Animation Library Designed for gesture-driven animations. Fast, simple, & extensible! It is written in pure swift 3.1 with protocol orient

Simple UIButton subclass with additional state change animations (e.g. backgroundColor) and missing features
Simple UIButton subclass with additional state change animations (e.g. backgroundColor) and missing features

SimpleButton UIButton subclass with animated, state-aware attributes. Easy to subclass and configure! Full API docs Usage Just create your own SimpleB

A concept to more easily define simple keyframe / multi-step animations in SwiftUI

🎞 Animate A concept to more easily define simple keyframe / multi-step animations in SwiftUI, without: Defining an @State value for each property to

UIView category that adds shake animation
UIView category that adds shake animation

UIView category that adds a shake animation like the password field of the OSX login screen. Screenshot Setup with CocoaPods Add pod 'UIView+Shake' to

UIView subclass that bends its edges when its position changes.

AHKBendableView BendableView is a UIView subclass that bends its edges when its position change is animated. Internally, BendableView contains CAShape

Twinkle is a Swift and easy way to make any UIView in your iOS or tvOS app twinkle.
Twinkle is a Swift and easy way to make any UIView in your iOS or tvOS app twinkle.

Twinkle ✨ Twinkle is a Swift and easy way to make any UIView in your iOS or tvOS app twinkle. This library creates several CAEmitterLayers and animate

DynamicBlurView is a dynamic and high performance UIView subclass for Blur.
DynamicBlurView is a dynamic and high performance UIView subclass for Blur.

DynamicBlurView DynamicBlurView is a dynamic and high performance UIView subclass for Blur. Appetize's Demo Since using the CADisplayLink, it is a hig

Type-safe CAAnimation wrapper. It makes preventing to set wrong type values.
Type-safe CAAnimation wrapper. It makes preventing to set wrong type values.

TheAnimation TheAnimation is Type-safe CAAnimation wrapper. Introduction For example, if you want to animate backgroundColor with CABasicAnimation, yo

🚀  It Makes easy to track your task 🔥 Beautiful & Animated UI👨🏻‍💻  . Contributions are always welcome 🤗
🚀 It Makes easy to track your task 🔥 Beautiful & Animated UI👨🏻‍💻 . Contributions are always welcome 🤗

Taskey 🚀 What is Taskey 🤔 ? Taskey is an application build in SwiftUI to track your task with a beautiful animations and UI . Also used core data to

Comments
  • Swift4 api addition

    Swift4 api addition

    This is a branch off of the swift 4 updated pull request. It adds a return value to all of the animate methods. The return value is the DaisyChain instance. This allows for a simpler syntax if the user prefers.

    i.e.

    let chain = DaisyChain()
    
    chain.animate(withDuration: 0.5, animations: {
        view.center = CGPoint(x: 0.0, y: 0.0)
    }).animate(withDuration: 0.5, animations: {
        view.center = CGPoint(x: 100.0, y: 0.0)
    }).animate(withDuration: 0.5, animations: {
        view.center = CGPoint(x: 100.0, y: 100.0)
    }).animate(withDuration: 0.5, animations: {
        view.center = CGPoint(x: 0.0, y: 100.0)
    }).animate(withDuration: 0.5, animations: {
        view.center = CGPoint(x: 0.0, y: 0.0)
    })
    
    opened by Nordeast 0
Owner
Ali Karagoz
Wizard @mojo_video_app. Created @suplco. Ex @gopro / @quik_app / @zenlyapp
Ali Karagoz
LottieView - Wrapper around Lottie in SwiftUI that allows chaining animations & triggering callbacks at certain frames

LottieView is a Wrapper around Lottie in SwiftUI that allows chaining animations & triggering callbacks at certain frames

Ahmed Ramy 0 Jan 23, 2022
A collection of animations for iOS. Simple, just add water animations.

DCAnimationKit A collection of animations for iOS Simply, just add water! DCAnimationKit is a category on UIView to make animations easy to perform. E

Dalton 797 Sep 23, 2022
Chain multiple UIView animations without endlessly nesting in completion closures.

⛓ Chain multiple UIView animations without endlessly nesting in completion closures. Used in some of the more superfluous animations in the OK Video app.

Pim 78 Dec 26, 2022
A micro-framework that leverages Swift Property Wrappers to implement the Service Locator pattern

Locatable Context Locatable is a Swift micro framework that leverages Property Wrappers to implement the Service Locator pattern, through a custom att

Vincent Pradeilles 116 Jan 9, 2022
Wave is a spring-based animation engine for iOS that makes it easy to create fluid, interruptible animations that feel great.

Wave is a spring-based animation engine for iOS and iPadOS. It makes it easy to create fluid, interactive, and interruptible animations that feel great.

Janum Trivedi 1.2k Jan 8, 2023
(Animate CSS) animations for iOS. An easy to use library of iOS animations. As easy to use as an easy thing.

wobbly See Wobbly in action (examples) Add a drop of honey ?? to your project wobbly has a bunch of cool, fun, and easy to use iOS animations for you

Sagaya Abdulhafeez 150 Dec 23, 2021
(Animate CSS) animations for iOS. An easy to use library of iOS animations. As easy to use as an easy thing.

wobbly See Wobbly in action (examples) Add a drop of honey ?? to your project wobbly has a bunch of cool, fun, and easy to use iOS animations for you

Sagaya Abdulhafeez 150 Dec 23, 2021
iOS framework for impressive transition animations between views.

CoreTransition iOS framework for impressive transition animations between views. Built using Swift, and supports a lot of animations to navigate to a

Ahmed Abdelkarim 4 Nov 17, 2022
Advanced Natural Motion Animations, Simple Blocks Based Syntax

FlightAnimator Moved to Swift 3.1 Support: For Swift 3.1 - Use tag Version 0.9.9 See Installation Instructions for clarification Introduction FlightAn

Anton 589 Dec 29, 2022