Giter VIP home page Giter VIP logo

dkchainableanimationkit's Introduction

This project is highly inspired by JHChainableAnimations, If you project is developed with Objective-C, use JHChainableAnimations instead.

With DKChainableAnimationKit

Using DKChainableAnimationKit, you do not need to write the extra parentheses.

view.animation.makeScale(2.0).spring.animate(1.0)

Installation with CocoaPods

CocoaPods is a dependency manager for Objective-C, which automates and simplifies the process of using 3rd-party libraries like DKNightVersion in your projects. See the Get Started section for more details.

Podfile

use_frameworks!

pod "DKChainableAnimationKit", "~> 2.0.0"

Installation with Carthage

Carthage is a depency manager for Objectiv-C and Swift.

Cartfile

github "Draveness/DKChainableAnimationKit"

Usage

Import DKChainableAnimationKit in proper place.

import DKChainableAnimationKit

DKChainableAnimationKit is designed to be extremely easy to use. First call animation method on UIView instance, and then add the animation you want followed by a animate(t) method.

view.animation.moveX(100.0).animate(1.0)

Animating

Chainable properties or functions like moveX(x) must come between the animate(duration) function.

view.animation.moveX(100.0).animate(1.0)

If you want mutiple animation at one time.

view.animation.moveX(100.0).moveY(100.0).animate(1.0)

This will move the view 100 point right and 100 point down at the same time. Order is not important.

Chaining Animations

To chain animations separate the chains with the thenAfter(duration) function.

view.animation.moveX(100.0).thenAfter(1.0).makeScale(2.0).animate(2.0)

This will move the view for one second and after moving, it will scale for two seconds.

Animation Effects

To add animation effect, call the effect method after the chainable property you want it to apply it.

Below is an example of moving a view with a spring effect.

view.animation.moveX(10).spring.animate(1.0)

If you add two animation effect, the first will be cancel out.

view.animation.moveX(10).spring.bounce.animate(1.0)
// The same as view.animation.moveX(10).bounce.animate(1.0)

Anchoring

To anchor your view call an anchoring method at some point in an animation chain. And if you add two anchoring property, the first will be cancel like effects.

view.animation.rotate(180).anchorTopLeft.thenAfter(1.0).rotate(90).anchorCenter.animanimation

Delay

To delay an animation call the wait(time) or delay(time) chainable function.

view.animation.moveXY(100, 40).wait(0.5).animate(1.0)
view.animation.moveXY(100, 40).delay(0.5).animate(1.0)
delay

This will move the view after 0.5 second delay.

Completion

If you want to run code after an animation finishes, you are supposed to set the animationCompletion property or call animateWithCompletion(t, completion) function.

view.animation.makeX(0).animateWithCompletion(1.0, {
    println("Animation Done")
})

This is the same as

view.animation.animationCompletion = {
    println("Animation Done")
}
view.animation.makeX(0).animate(1.0)

And also the same as

view.animation.makeX(0).animate(1.0).animationCompletion = {
    println("Animation Done")
}

Bezier Paths

You can also animate a view along a UIBezierPath. Call bezierPathForAnimation method first and then add points or curves to it and us it in a chainable property.

let path = view.animation.bezierPathForAnimation()
path.addLintToPoint(CGPoint(x: 30, y: 40))
view.animation.moveOnPath(path).animate(1.0)

Animation effects does not work on path movement.


Chainable Properties

moveX(100.0)
moveY(100.0)
moveWidth(100.0)
moveHeight(100.0)
moveXY(100.0, 100.0)
makeX(100.0)
makeY(100.0)
makeOrigin(100.0, 100.0)
makeCenter(100.0, 100.0)
makeWidth(100.0)
makeHeight(100.0)
makeSize(100.0, 100.0)
makeFrame(rect) // let rect: CGRect
makeBounds(rect) // let rect: CGRect
makeScale(2.0)
makeScaleX(2.0)
makeScaleY(2.0)
makeOpacity(0.0)
makeBackground(purple) // let purple: UIColor
makeBorderColor(red) // let red: UIColor
makeBorderWidth(10.0)
makeCornerRadius(25.0)

To Do

  • Support OS X
  • Support Swift 2.0

Contact

  • If you have some advice open an issue or a PR.
  • Email [Draveness](mailto: [email protected])

License

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

dkchainableanimationkit's People

Contributors

apouche avatar charlesmassry avatar colinmorelli avatar draveness avatar mathiasnagler avatar obohrer avatar quad avatar tomisacat 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

dkchainableanimationkit's Issues

Can not use right with makeFrame

I have a small issue. I want to set a view from CGRect(10,60,1,1) to CGRect(10,60,100,100), the size is good but the origin wrong. I print object and that is new origin of view:
▿ CGRect
▿ origin : CGPoint

  • x : -39.5
  • y : 10.5 { ... }
    ▿ size : CGSize
  • width : 100.0
  • height : 100.0 { ... }
    I use makeFram(rect: CGRect) in your lib. Please help me resolve this issue

I had to add "import DKChainableAnimationKit" to make it work.

Great library!

Whiteout the line "import DKChainableAnimationKit", I got the error "X doesn't have a member named animation".

It might be nice to add this to the documentation, or am I doing something wrong? I installed the library via Cocoapods.

Animating Constraints

It seems that this library is API-complete with respect to JHChainableAnimations, with the exception of the constraints portion. Any plan to implement those?

Thanks!

Animation trouble using Timer

Basically I have a sidemenu that I am using DKChainableAnimationKit to both show and hide my sidebar, which works perfect. However, I have noticed that when I've been using timers, the animation seem to crash. For instance, I have a timer that counts down from 10 to 0, basically by decreasing the global integer by 1, every second. When I make the countdown start, and click the button to show the sidebar - it suddenly disappears. To avoid this, I have been trying to do a .makeOrigin after the animation has been done - with no luck. I have also tried to do the countdown in the timer update function running async, also with no luck.

Any ideas on how I would approach this?

Here is my code:

Button for showing sidebar:
self.sideview.animation.moveX(350).easeInOutSine.animate(0.5)

Timer:
self.countdownText = Foundation.Timer.scheduledTimer(timeInterval: 1.0, target: self, selector: #selector(ViewController.counter), userInfo: nil, repeats: true)

Counter Function:

func counter() {
            self.count = Int(self.count - 1) //When I add this line, the animation disappears (or the sidebar)
            self.newGameLabel.text = String(self.count) //This line works, without any error.
        }

    }

Could someone please help me to fix this? Much appreciated.

Doesn't compile in XCode 9.2 with Swift 4

Hi!
I installed DKChainableAnimationKit through CocoaPods and unfortunately it doesn't compile.
I keep getting this error "Missing argument for parameter #1 in call" and three warnings. Please see the attached screenshot

screen shot 2017-12-14 at 3 10 11 pm

Keyframe caculator Funtions: easeInCirc,...

Hi,
I try to use some func like easeInCirc, easeInOut,.... make my view move to a rect. But it just move simple, straight line.
This is my code:
v.animation.makeOrigin(300, 100).easeInCirc.animateWithCompletion(1.0, {
self.v.frame = CGRectMake(100, 400, 10, 10)
sender.userInteractionEnabled = true
})
Did i use wrong? plz help me

Podfile + Xcode 8

pod "DKChainableAnimationKit", "~> 1.6.1"

But it downloads something old, however version is 1.6.1. Swift 2.2 alike.
Cleaned cached in cocoapods, but didn't help.

Animating Background Color Crashing

When you use the method makeBackground with a basic default monotone colors that are created using the UIColor convenience methods, like UIColor.black, UIColor.white, UIColor.gray, etc., the app crashes because the way it finds the color components. In Swift 3 with iOS 10 these methods return a color with only two components, a darkness value and an alpha value. This does not cause an issue with colors like UIColor.red or UIColor(red: 0.0, blue: 0.0, green: 0.0, alpha: 1.0) however. I will be able to make a fix if you'd like.

not working xcode 7.3

HI,
I am using xocde 7.3. After installing pod file the xcode shows many syntax errors in the follwing swift files DKChainableAnimationKit+Anchor.swift, DKChainableAnimationKit.swift, DKKeyFrameAnimation.swift

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.