facebookarchive / pop

An extensible iOS and OS X animation library, useful for physics-based interactions.
Other
19.66k stars 2.88k forks source link

Query the target value of a currently running animation #309

Closed sbudhram closed 8 years ago

sbudhram commented 8 years ago

I'm trying to query the final value of a currently running POPSpringAnimation. I get the value by querying [ pop_animationForKey:], casting to a POPPropertyAnimation, and getting the 'to' attribute value (in my case, I'm animating the frame, so my return value is NSValue of type CGRect). The problem is that this value seems to be for the current segment of the spring animation, not the final result value of the animation - so it varies drastically depending on the stage of the animation. Does a POP animation object store the true final value of the animation somewhere?

grp commented 8 years ago

You can use the toValue property to read out the target of the animation. That property is configured when setting up the animation, though, so it should already be available to your code.

If you're looking for the maximum value, not the final value, then Pop doesn't provide access to that in advance. The simulation in Pop is progressed incrementally and so a complete path isn't known until the simulation reaches that point.