JNWSpringAnimation

Spring physics for Core Animation.

  • 所有者: jwilling/JNWSpringAnimation
  • 平台:
  • 許可證: MIT License
  • 分類:
  • 主題:
  • 喜歡:
    0
      比較:

Github星跟蹤圖

JNWSpringAnimation

JNWSpringAnimation is a subclass of CAKeyframeAnimation that adds support for creating damped harmonic animations.

Getting Started

Although JNWSpringAnimation is a subclass of CAKeyframeAnimation, it should be treated as if it were a subclass of CABasicAnimation.

To get started, copy the four source files into your project.

The animation can be created by using the dedicated initializer, +animationWithKeyPath:. Alternatively, the animation can be created using +animation and by setting the key path afterwards. The full list of currently-compatible animatable properties is available in the header.

JNWSpringAnimation *animation = [JNWSpringAnimation animationWithKeyPath:@"position.x"];

Next, the fromValue and toValue properties must be set for the interpolated values to be calculated correctly.

animation.toValue = @(toX);
animation.fromValue = @(currentX);

Finally, the values for the spring constants can optionally be changed. Currently, stiffness, damping, and mass are available for modification.

animation.mass = 30; // this will move extremely slowly
// and so on

The animation itself can be applied like any other subclass of CAAnimation, namely -addAnimation:forKey: on any CALayer.

What's this for?

This was created in my desire to have an open-source version of the (currently private) CASpringAnimation which was discovered in iOS 6.

Spring animations, when used appropriately, can really enhance the way your app feels to the user by connecting in physical simulations with an app's interface. And besides, who doesn't love messing around with springs?

What's left to do?

I created this as a weekend project, so the implementation is still somewhat unfinished. Compared to CASpringAnimation, the velocity property is still unimplemented. Pull requests are welcome.

License

JNWSpringAnimation is licensed under the MIT license. See LICENSE.md.

Get In Touch

You can follow me on Twitter as @willing, email me at the email listed on my GitHub profile, or read my blog at jwilling.com.

主要指標

概覽
名稱與所有者jwilling/JNWSpringAnimation
主編程語言Objective-C
編程語言Objective-C (語言數: 2)
平台
許可證MIT License
所有者活动
創建於2013-06-03 01:50:51
推送於2017-05-31 09:43:00
最后一次提交2017-03-12 10:27:33
發布數8
最新版本名稱0.7.1 (發布於 2015-05-20 12:07:51)
第一版名稱0.1 (發布於 2013-06-03 10:27:11)
用户参与
星數1k
關注者數44
派生數68
提交數45
已啟用問題?
問題數2
打開的問題數0
拉請求數9
打開的拉請求數0
關閉的拉請求數1
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?