Giter Site home page Giter Site logo

animo's Introduction

Animo

Version Platform License Carthage compatible

Bring life to CALayers with SpriteKit-like animation builders.

preview

Why use Animo?

Because declaring CAAnimations (especially with CAAnimationGroups) is very verbose and tedious.

Animo turns this:

let positionAnimation = CABasicAnimation(keyPath: "position")
positionAnimation.fromValue = NSValue(CGPoint: fromPoint)
positionAnimation.toValue = NSValue(CGPoint: toPoint)

let colorAnimation = CABasicAnimation(keyPath: "backgroundColor")
colorAnimation.fromValue = fromColor.CGColor
colorAnimation.toValue = toColor.CGColor

let animationGroup = CAAnimationGroup()
animationGroup.animations = [positionAnimation, colorAnimation]
animationGroup.fillMode = kCAFillModeForwards
animationGroup.removedOnCompletion = false
animationGroup.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)

someView.layer.addAnimation(animationGroup, forKey: "animationGroup")

to this:

someView.layer.runAnimation(
    Animo.group(
        Animo.move(from: fromPoint, to: toPoint, duration: 1),
        Animo.keyPath("backgroundColor", from: fromColor, to: toColor, duration: 1),
        timingMode: .EaseInOut,
        options: Options(fillMode: .Forwards)
    )
)

Feature List

  • All timing modes from http://easings.net/ are implemented.
  • Choose how to mix your animations with grouping utilities:
    • group(...)
    • sequence(...)
    • autoreverse(...)
    • wait(...)
    • replay(...) and replayForever(...)
  • No need to box native types and struct types in NSValues! Animo will do that for you for:
    • Int8
    • Int16
    • Int32
    • Int64
    • UInt8
    • UInt16
    • UInt32
    • UInt64
    • Int
    • UInt
    • CGFloat
    • Double
    • Float
    • CGPoint
    • CGSize
    • CGRect
    • CGAffineTransform
    • CGVector
    • CATransform3D
    • UIEdgeInsets
    • UIOffset
    • NSRange
  • No need to bother between CGColor and UIColor! Animo automatically converts the following types for you so you can just use UIKit objects all the time:
    • UIColorCGColor
    • UIImageUIImage
    • UIBezierPathCGPath
  • Don't bother type-casting M_PI anymore and just use Degrees-to-Radians (and vice-versa) extensions for CGFloat, Double, and Float!

Here's a slightly complex animation that showcases what else you can do with Animo:

someView.layer.runAnimation(
    Animo.sequence( // Runs a list of animations in sequence
        Animo.wait(1), // Waits for a certain interval before running the next animation
        Animo.replayForever( // Replays the animation endlessly
            Animo.sequence(
                Animo.move( // Moves the layer's position
                    by: CGPoint(x: 100, y: 200), // "by", "from", and "to" arguments are supported
                    duration: 2,
                    timingMode: .Spring(damping: 1) // simplistic spring function that doesn't rely on physics
                ),
                Animo.rotateDegrees( // Rotates the layer (degrees and radians variants are supported)
                    by: -180,
                    duration: 1,
                    timingMode: .EaseInOutBack
                ),
                Animo.autoreverse( // Auto-reverses the animation
                    Animo.keyPath(
                        "cornerRadius", // Any custom KVC key is supported as well!
                        to: 10,
                        duration: 1,
                        timingMode: .EaseInOutBack
                    )
                ),
                Animo.group( // Runs multiple animations together
                    Animo.scaleX(
                        by: 2,
                        duration: 1,
                        timingMode: .EaseInOutBack
                    ),
                    Animo.scaleY(
                        by: 0.5,
                        duration: 1,
                        timingMode: .EaseInOutBack
                    )
                ),
                Animo.wait(1),
                Animo.move(
                    by: CGPoint(x: -100, y: -200),
                    duration: 2,
                    timingMode: .EaseInOutBack
                ),
                Animo.rotateDegrees(
                    by: 180,
                    duration: 1,
                    timingMode: .EaseInOutBack
                ),
                Animo.group(
                    Animo.scaleX(
                        to: 1,
                        duration: 1,
                        timingMode: .EaseInOutBack
                    ),
                    Animo.scaleY(
                        to: 1,
                        duration: 1,
                        timingMode: .EaseInOutBack
                    )
                )
            )
        )
    )
)

Install with CocoaPods

Add

pod 'Animo'

to your Podfile and run pod install

Install with Carthage

Add

github "eure/Animo" >= 1.2.0

to your Cartfile and run carthage update

Install as Git Submodule

Run

git submodule add https://github.com/eure/Animo.git <destination directory>

To install as a framework:

Drag and drop Animo.xcodeproj to your project.

To include directly in your app module:

Add all .swift files to your project.

License

Animo is released under an MIT license. See the LICENSE file for more information.

animo's People

Contributors

johnestropia avatar readmecritic avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

animo's Issues

rotate using an enum type

Great lib ! One improvement would be to use an enum type inside a common rotate method like such:

Animo.rotate(.Degree(-180))
Animo.rotate(.Radian(-M_PI))

Definitely a nice to have, what do you think ?

completion handler?

Nice library! ... I couldn't find an easy way to add a completion handler...ideas?

Can't interact with UIView after animation

Hi there.

Basically I am having issues interacting with segments I have inside my UIView after an animation has been done. In other words, I can't seem to click any button, or scroll any text view. How come?

I have tried to play with completion blocks, and do myView.isUserInteractionEnabled = true etc. Any ideas on how I can fix this? If I stop the animation, the UIView moves back to the position I don't want it to be in. In other words, I want it to stay.

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.