Git Product home page Git Product logo

chainedanimation's Introduction

ChainedAnimation

Build Status Version License Platform

Usage

To run the example project, clone the repo, and run pod install from the Example directory first.

Chain multiple animations with different delays. Chained animations will be started with a delay after the last one started executing.

You can create a chained animation with the -beginAnimationChain function on the UIView class.

UIView.beginAnimationChain(0.5) {
  view.frame.origin.y = 170
}.animate()

You can provide an optional delay an UIViewAnimationOptions.

UIView.beginAnimationChain(0.5, delay: 0.2, options: .CurveEaseInOut) {
  view.frame.origin.y = 170
}.animate()

To add an offset animation, use the -thenAfterStart: function and append an animation closure that will be executed as soon as the last animation started, delayed by the provided offset. Add a completion closure to the animation chain and it will be executed when the previous animation in the chain completed.

UIView.beginAnimationChain(0.5, options: .CurveEaseInOut) {
  view.frame.origin.y = 170
}.thenAfterStart(0.1) {
  // This animation will be started 0.1 seconds
  // after the previous one started
  otherView.tranform = awesomeTransform
}.thenAfterStart(0.15) {
  // More shiny animations
}.completion { bool in
  // Do something nice on completion. Or don't.
}.animate()

It is also possible to add a new chain after a previous one completed. To add a new chain call -chainAfterCompletion: and start adding animation blocks with their offset.

UIView.beginAnimationChain(0.33, options: .CurveEaseInOut) {
  view.frame.origin.y = 170
}.thenAfterStart(0.15) {
  // Start animations with a delayed start
}.completion { bool in
  // Do something nice on the completion of the first chain.
}.chainAfterCompletion(1.2, options: .CurveEaseIn) {
    // This animation will be started after the last
    // animation in the first chain completed
}.thenAfterStart(0.1) {
    // This animation will be started 0.1 seconds after
    // the first animation in the second chain started
}.completion { _ in
    // Do something nice on the completion of the second chain.
}.animate()

Installation

ChainedAnimation is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "ChainedAnimation"

Author

Silvan Dähn, @silvandaehn

License

Chain is available under the MIT license. See the LICENSE file for more info.

chainedanimation's People

Contributors

daehn avatar

Watchers

James Cloos avatar ChrisyehGone avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.