This repository was archived by the owner on Mar 3, 2020. It is now read-only.

Description
TL;DR: If the toValue of an animation equals the target's current value (even if the fromValue does not) then the completionBlock will be called immediately with a truthy completed value.
Imagine we have a red square we've hidden by setting it's alpha to 0.0.
Now we want to flash it in to alpha 1.0 and slowly fade it out.
We might add a basic animation like this:
let view = UIView(frame: CGRect(x: 0, y: 0, width: 100, height: 100))
view.backgroundColor = .magenta
view.alpha = 0.0
addSubview(view)
let flashAndFadeAnimation = POPBasicAnimation(propertyNamed: kPOPViewAlpha)!
flashAndFadeAnimation.duration = 10.0
flashAndFadeAnimation.timingFunction = CAMediaTimingFunction.cubicOut()
flashAndFadeAnimation.fromValue = 1.0
flashAndFadeAnimation.toValue = 0.0
flashAndFadeAnimation.completionBlock = { [weak self] (animation, completed) in
print("completed at: \(Date())")
}
print("animation added at: \(Date())")
view.pop_add(flashAndFadeAnimation, forKey: "flashAndFade")
The result is that the completionBlock will be called immediately despite the animation itself taking 10 seconds and properly animating.
This elusive bug has bitten me for years and I've only now connected the dots. 😆
I'd love to create a PR if anyone with intimate knowledge of the library could help set me off in the right direction to patch it and add the proper tests.