GithubHelp home page GithubHelp logo

augustrush / stellar Goto Github PK

View Code? Open in Web Editor NEW
2.9K 68.0 228.0 13.78 MB

A fantastic Physical animation library for swift

License: MIT License

Swift 99.65% Ruby 0.21% Objective-C 0.14%
curve animation physical uidynamics swift-3 ios

stellar's Issues

When I use OC, import the swift code, found that there is no easing and other methods


@interface CALayer (SWIFT_EXTENSION(Stellar))
@EnD

@interface UIColor (SWIFT_EXTENSION(Stellar))

  • (void)fallTo:(UIColor * _Nonnull)to magnitude:(double)magnitude render:(void (^ _Nonnull)(UIColor * _Nonnull))render completion:(void (^ _Nullable)(void))completion;
  • (void)snapTo:(UIColor * _Nonnull)to damping:(CGFloat)damping render:(void (^ _Nonnull)(UIColor * _Nonnull))render completion:(void (^ _Nullable)(void))completion;
  • (void)attachmentTo:(UIColor * _Nonnull)to damping:(CGFloat)damping frequency:(CGFloat)frequency render:(void (^ _Nonnull)(UIColor * _Nonnull))render completion:(void (^ _Nullable)(void))completion;
  • (void)pushedTo:(UIColor * _Nonnull)to render:(void (^ _Nonnull)(UIColor * _Nonnull))render completion:(void (^ _Nullable)(void))completion;
    @EnD

@interface UIDynamicBehavior (SWIFT_EXTENSION(Stellar))
@EnD

@Class UIView;

@interface UILabel (SWIFT_EXTENSION(Stellar))

  • (UIView * _Nonnull)makeTextColor:(UIColor * _Nonnull)color;
    @EnD

@interface UITextView (SWIFT_EXTENSION(Stellar))

  • (UIView * _Nonnull)makeTextColor:(UIColor * _Nonnull)color;
    @EnD

@interface UIView (SWIFT_EXTENSION(Stellar))

  • (BOOL)configureWithJSON:(NSString * _Nonnull)str error:(NSError * _Nullable * _Null_unspecified)error;
    @EnD

@interface UIView (SWIFT_EXTENSION(Stellar))

  • (UIView * _Nonnull)moveX:(CGFloat)increment;
  • (UIView * _Nonnull)moveY:(CGFloat)increment;
  • (UIView * _Nonnull)moveTo:(CGPoint)point;
  • (UIView * _Nonnull)makeColor:(UIColor * _Nonnull)color;
  • (UIView * _Nonnull)makeAlpha:(CGFloat)alpha;
  • (UIView * _Nonnull)rotate:(CGFloat)z;
  • (UIView * _Nonnull)rotateX:(CGFloat)x;
  • (UIView * _Nonnull)rotateY:(CGFloat)y;
  • (UIView * _Nonnull)rotateXY:(CGFloat)xy;
  • (UIView * _Nonnull)makeWidth:(CGFloat)width;
  • (UIView * _Nonnull)makeHeight:(CGFloat)height;
  • (UIView * _Nonnull)makeSize:(CGSize)size;
  • (UIView * _Nonnull)makeFrame:(CGRect)frame;
  • (UIView * _Nonnull)makeBounds:(CGRect)bounds;
  • (UIView * _Nonnull)scaleX:(CGFloat)x;
  • (UIView * _Nonnull)scaleY:(CGFloat)y;
  • (UIView * _Nonnull)scaleXY:(CGFloat)x :(CGFloat)y;
  • (UIView * _Nonnull)cornerRadius:(CGFloat)radius;
  • (UIView * _Nonnull)borderWidth:(CGFloat)width;
  • (UIView * _Nonnull)shadowRadius:(CGFloat)radius;
  • (UIView * _Nonnull)zPosition:(CGFloat)position;
  • (UIView * _Nonnull)anchorPoint:(CGPoint)point;
  • (UIView * _Nonnull)anchorPointZ:(CGFloat)z;
  • (UIView * _Nonnull)shadowOffset:(CGSize)offset;
  • (UIView * _Nonnull)shadowColor:(UIColor * _Nonnull)color;
  • (UIView * _Nonnull)shadowOpacity:(float)opacity;
  • (UIView * _Nonnull)makeTintColor:(UIColor * _Nonnull)color;
  • (UIView * _Nonnull)completion:(void (^ _Nonnull)(void))c;
  • (UIView * _Nonnull)then;
  • (UIView * _Nonnull)then;
  • (void)animate;
  • (void)cancelAllRemaining;
    @EnD

Update library in Cocoapods

Hi,

Interesting library!

Latest release here is 0.66, while on pods you can only find 0.61. Any reason to keep it that way? Could you update it there too? So we don't need to point this specific branch.

Thank you,
H.

Pod

Would be amazing if this could be installed using CocoaPods :)

Stellar does not play well with Carthage

For months now I have problem using Stellar with Carthage. I have to ways to solve the problems: 1/ by "manually" building Stellar framework after changing stuff in Xcode project or 2/ by adding sources to my project. But as for now the last option does not work because the code imported using Carthage is not the last one on GitHub...

So there is definitely something wrong with Carthage.

Spanish translate

Hello, I would like to collaborate with the Spanish translation, is it done?

scaleXY doesn't work as expected

Unless the library works differently it is ususally expected that a scale of 1 always return the identity matrix scalling column back.

However here with Stellar (and thanks for you great work btw), this not the case.
A simple exemple with

myView.scaleXY(0.9,0.9).animate()
// later on: 
myView.scaleXY(1.0,1.0).animate()

shows that the scaling factor of 1.0 leave the scale of the view unchanged.
And changing the second call to myView.scaleXY(1.1,1.1).animate() doesn't return the view to its original scale either (that, I have trouble understanding).

If you have any question regarding this, let me know :)

"Unsupport this animation type!" exception

With 0.66 this exception is thrown on very basic animation:

myView.makeAlpha(0.0)
      .duration(aDuration)
      .autoreverses()
      .repeatCount(someRepetitions)
      .completion {
            // Some statements
              myView.removeFromSuperview()
            }
      .animate()

Let's say it's a find of flash.

I tried other animation like makeSizeor makeColor but same behavior.

This flash portion of code is called several times on a sequence basis. On the first call everything is fine. The exception is raises on the second call.
Between these two calls of flash there is an animation using CATransaction. On the completion block of this animation the second call of flash is then made.

CATransaction.begin()
CATransaction.setCompletionBlock({
      // call to flash animations
})

...

CATransaction.commit()

This error came after I decided to use CATransaction to use it's completion block.

Affine Transform

What are your thought about this?

Oftentimes I need to also animate affine scale. However this one is not supported by stellar. I wrote the following set of extensions to make it uniform with Stellar's syntax.

What are your thoughts? Do you see any systemic issue?

`struct CABasicAnimatedView {

let view: UIView
let animation: CABasicAnimation

}

extension UIView {

func makeAffineUniformScale(from from: CGFloat, to: CGFloat) -> CABasicAnimatedView {
    
    let animation = CABasicAnimation(keyPath: KeyPaths.Transform.scale)
    let animatedView = CABasicAnimatedView(view: self, animation: animation)
    
    animatedView.animation.fromValue = from
    animatedView.animation.toValue = to
    
    return animatedView
}

}

extension CABasicAnimatedView {

func duration(duration: NSTimeInterval) -> CABasicAnimatedView {
    
    self.animation.duration = duration
    
    return self
}

func timingFunction(timingFunction: CAMediaTimingFunction) -> CABasicAnimatedView {
    
    self.animation.timingFunction = timingFunction
    
    return self
}

func animate() {
    
    CATransaction.begin()
    self.view.layer.addAnimation(self.animation, forKey: nil)
    CATransaction.commit()
    
    self.view.transform = CGAffineTransformMakeUniformScale(self.animation.toValue as! CGFloat) }

}

func CGAffineTransformMakeUniformScale(scale: CGFloat) -> CGAffineTransform {

return CGAffineTransformMakeScale(scale, scale)

}`

"has no member" error

I want to use Stellar with my project but I have this Value of type 'UIView' has no member error in my very first attempt to use Stellar on an UIView.

I use Carthage to install Stellar the same way as other libraries. It's like Stellar is not "installed". Installation using Stellar 0.65 is OK, and the usual Carthage installation has been followed.
Then, I used the direct inclusion of Sourcesdirectory and everything is fine.

I have clean project. This is a weird behavior... Any idea? Is there special configuration for Carthage command?

太赞了

不知不觉又新推出一开源项目

How to "glue" animation

I want to design an animation by chaining several animations in a programmatically way.

I tried the following without success:

aView = aView.moveX(5.0).duration(2.0).completion({ do_something() }).then()
...
aView = aView.moveX(7.0).duration(1.0).completion({ do_something() }).then()

aView.animate()

How to achieve this?

Future

Hi,

I am using the library with solid success. However I am a bit stressed by the stale development lately. What are your plans honestly?

cancel/remove all animations

Still awesome animation library. Loving it the more I use it.

Feature request. Would be nice if I could call cancelAllAnimations() on a UIView. and it'll stop all ongoing and planned animations.

makeAlpha seems not working

Hi,

Seems that makeAlpha is not working, or maybe I'm doing something wrong.
Can you add an example of how to use it on the demo view controllers?

Thanks

Buggy examples

just run any example from demo and click multiple times - animation breaks

Swift 3 errors

I love Stellar. Animations with Swift like they should be. Thanks.
but...
Swift 3 branch seems to throw compile errors. Any plans on fixing this? Swift 3 officially out today.
thanks.

Using makeAlpha on 0.66 generates crash

Using makeAlpha of 0.66 generates the Unsupport this animation type!
(btw, Unsupport is not word ... Do not support this animation type! is better)

Reverting back to 0.65 fixed the issue by using the following in the Podfile
pod 'Stellar', :git => 'https://github.com/AugustRush/Stellar', :commit => '5249167900b1eb136ce71543af7817a9fa5535cb'

Unable into install via CocoaPods

I've noticed there's a podspec file available but some for strange reason I can't find the repo on CocoaPods.

pod 'Stellar'

Returns a Unable to find a specification for Stellar error.

Although downloading straight from the source works.

pod 'Stellar', :git=>'https://github.com/AugustRush/Stellar.git'

Does it work with autolayout ?

Hi, I have just got an issue when I try to animate the appearance of a view by extending its width from 0 to full width, from left to right.

view.makeFrame(CGRect(origin: origin, size: CGSize(width: 0, height: view.bounds.height))).makeAlpha(1).duration(0).then()
            .makeFrame(CGRect(origin: origin, size: CGSize(width: width, height: view.bounds.height))).duration(1).animate()

The view is expected to extend from the origin of the view.

            |                                                   |               
            |----->-------------->-----------------------------
            |                                                   |  
            |                                                   |  
            |                                                   | 

(view left border) (view right border)

However, it did extend from the center of the view.

            |                                                   |               
            |                           ---->------------->---------------------------
            |                                                   |  
            |                                                   |  
            |                                                   |  

In the storyboard, autolayout of this view is set as having 0 padding to the left border of the container.

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.