Git Product home page Git Product logo

theanimation's Introduction

TheAnimation

CI Status Platform Language Carthage compatible Version License

TheAnimation is Type-safe CAAnimation wrapper.

Introduction

For example, if you want to animate backgroundColor with CABasicAnimation, you need to consider type because fromValue property and so on are Any?.

If you use BasicAnimation of TheAnimation, you can animate backgroundColor without considering type! (AnimationKeyPaths.backgroundColor is AnimationKeyPath<CGColor> type.)

Usage

The way of making an animation is almost similar CAAnimation. But you need to use animation.animate(in:) method instead of using layer.add(_:forKey:).

let view = UIView()

let animation = BasicAnimation(keyPath: .opacity)
animation.fromValue = 0
animation.toValue   = 1
animation.duration  = 1
animation.animate(in: view)

animation.animate(in:) returns AnimaitonCanceller. You can cancel an animation with it.

let canceller = animation.animate(in: view)
canceller.cancelAnimation()

Example

To run the example project, clone the repo, and open Example directory.

Correspondence Table

CAAnimation TheAnimation
CAPropertyAnimation PropertyAnimation
CABasicAnimation BasicAnimation
CAKeyframeAnimation KeyframeAnimation
CASpringAnimation SpringAnimation
CATransition TransitionAnimation
CAAnimationGroup AnimationGroup

Add new AnimationKeyPath

You can add AnimationKeyPath like this.

extension AnimationKeyPaths {
    static let newKeyPath = AnimationKeyPath<CGFloat>(keyPath: "abcd")
}

Requirements

  • Xcode 9.3
  • iOS 9 or greater

Installation

Carthage

If you’re using Carthage, simply add TheAnimation to your Cartfile:

github "marty-suzuki/TheAnimation"

CocoaPods

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

pod 'TheAnimation'

Author

marty-suzuki, [email protected]

License

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

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.