ios platform 12
JJValueAnimator is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'JJValueAnimator'
To run the example project, clone the repo, and run pod install
from the Example directory first.
ValueAnimator makes the transition from initial value to target.
Simple Linear Animation
import JJValueAnimator
let anim = JJValueAnimator.ofFloat(0, to: 100).addUpdateListener({
[weak self ] (value) in
// do something with value
})
.setDuration(400) // millis
anim.start()
The time interpolator used in calculating the elapsed fraction of the animation. The default value is Linear.
Intepolators start with JJInterpolator.
import JJValueAnimator
let anim = JJValueAnimator...
anim.setInterpolator(JJInterpolator(ease: .ANTICIPATEOVERSHOOT))
// or
anim.setInterpolator(JJInterpolatorCycle(cycles: 4))
You need to implement the JJTimeInterpolator protocol
class MyInterpolator : JJTimeInterpolator{
override func getInterpolation(input: Float) -> Float {
//do the magic
}
}
anim.setInterpolator(MyInterpolator())
There are JJAnimatorListener y JJAnimatorPauseListener
anim.addListener(OnAnimationListener(self))
anim.addPauseListener(MyAnimatorPauseListener(self))