material-motion-swift icon indicating copy to clipboard operation
material-motion-swift copied to clipboard

Property chaining can cause over-completion of core animation animations

Open jverkoey opened this issue 8 years ago • 0 comments
trafficstars

Scenario:

  1. Add a Tween or Spring to a property.
  2. Connect that property to another property.

When the interaction emits its animation event on the core animation channel, the info will be propagated to the first property and then the second. Both will add an animation with a CATransaction using the provided completion handler. Because these are two individual animations, each completion handler will be invoked individually, causing the interaction's completion handler to be invoked twice.

In practice this won't be particularly noticeable because the timings for both animations should be similar, but there is a chance that this could cause an interaction to be marked as completed before all animations have, in fact, completed.

A potential solution here is to create an intermediary counting completion handler that supports being added to multiple transactions. This handler would propagate up to the original handler once all known animations have completed.

jverkoey avatar Mar 28 '17 01:03 jverkoey