Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Completion block / closure never fires when using m_animate #1

Closed
mitchellporter opened this issue Mar 9, 2016 · 4 comments
Closed

Comments

@mitchellporter
Copy link

Hey Luke,

First off thanks for releasing this library I love the way the motion looks. It's my new favorite animation library :)

I'm using a pan gesture to allow the user to move an object around the screen. I noticed that none of the completion blocks / closures were firing so I started adding breakpoints to your library. For some reason the code just keeps running, even after the animation has finished on the screen.

I can't seem to figure out why it keeps running and never wants to stop. Any chance I can get your help on this? Thanks.

@lkzhao
Copy link
Owner

lkzhao commented Mar 9, 2016

I have a new version with many bug fixes and perf optimization for this soon. In the mean time try setting MotionAnimator.sharedInstance.debugEnabled to true and see if the animator actually stops when your animation ends.

@mitchellporter
Copy link
Author

@lkzhao Hey Luke I figured it out after a few hours of banging my head against the wall :)

I looked over your example code for any differences I could find and I noticed you were setting the threshold parameter to 1. I had been setting all of mine to zero which was causing the animations to run forever. Even just applying a threshold of 0.1 fixes the problem, so nothing wrong with your code, it was purely my fault.

I wanted to say thanks again for creating this. I'm a huge fan of realistic motion animations and a lot of the animation libraries available, including Facebook POP, feel very cluttered.

I love the simplicity of this library. Please let me know if you ever need any help or feedback.

Cheers ;)

@mitchellporter
Copy link
Author

I have a new version with many bug fixes and perf optimization for this soon.

Also, I'd be happy to test this out for you if you want. Thanks again for the help!

@lkzhao
Copy link
Owner

lkzhao commented Mar 9, 2016

@mitchellporter
I should have raised an warning about setting threshold to zero. I will include that in the upcoming release.
Basically the threshold determines when the sprint animation terminates. When the difference between target/current value and the velocity drop within the threshold, the spring animation stops.

Thank you for being an early adopter though. I also use this library in one of my upcoming app and noticed some performance problems. There is also a lot of hard-to-read code just to support animating objective-c KVO properties.

So I am thinking about deprecating these two files.

  • MotionAnimationPropertyState.swift
  • NSObject+MotionAnimation.swift
    Because they add a lot of complexity and performance hit.

For the most part, this library is working elegantly with the following four classes:

  • MotionAnimator
  • MotionAnimation
  • ValueAnimation
  • SpringValueAnimation

If you look into UIView+MotionAnimation.swift file you can see a custom animation PositionAnimation built to animate a CGPoint property. I tested it against the m_animate version and found that it is many times faster.

Right now I am still thinking about a clever way to animate any values without creating a custom animation and losing performance. Stay tuned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants