Giter VIP home page Giter VIP logo

Comments (3)

draveness avatar draveness commented on May 31, 2024

YES, it is really interesting. When I found the animation syntax is so concise and elegant. I have tried to use this syntax to set up UIKit component ChainableKit But it is a little weird. I think this syntax works well with animation but not such well with UIKit.

The suggestion is also very great. And it still needs much more work... I will try it figure it out and see whether it is better way to add constraint to UIKit component.

Thanks so much.

from dkchainableanimationkit.

cannyboy avatar cannyboy commented on May 31, 2024

ChainableKit looks really good.

I'm trying to think about what would be the most concise, DRY, and readable syntax, which combines setting properties, animating and constraints (and animating constraints).

To produce this:

gif

.. you could have something like this:

var greenView = UIView()
greenView.set.backgroundColor(UIColor.greenColor()).alpha(0.5) // 'set' to chain properties
view.addSubview(greenView)
greenView.constrain.top.bottom.left.equalTo(view) // 'constrain' to make (and chain) constraints 
greenView.constrain.width.equalTo(view).multipliedBy(0.25)

var redView = UIView(frame:CGRectMake(0, 0, 100, 100))
redView.backgroundColor = UIColor.redColor()
view.addSubview(redView)

greenView.constrain.width.equalTo(view).multipliedBy(0.5).spring.animate(1.0) {
    self.greenView.animate.alpha(1.0).animate(1.0).
    self.redView.animate.moveXY(200,200).delay(0.5).spring.animate(0.5)
}

That’s about 10 lines, 620 characters.

If done without any libraries - https://gist.github.com/cannyboy/dabe7a9f487338e07830 - it would be maybe 40 lines - about 2500 characters.

from dkchainableanimationkit.

jhurray avatar jhurray commented on May 31, 2024

@cannyboy I responded to your issue on SnapKit. There are some reasons that that syntax wont work (or at least it would be very difficult to make it work). I am thinking of adding a chainable property that takes a NSLayoutContraint and a value and animates the change of the constant.

So if you use SnapKit or Masonry to reference a constraint you could then say

self.myView.makeConstraint(self.myConstraint, 50).animate(1.0);

I just want to make sure this works 100% of the time and conforms to apples API.

from dkchainableanimationkit.

Related Issues (20)

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.