Skip to content
This repository has been archived by the owner on Aug 30, 2023. It is now read-only.

Disable implicit animations when adding explicit animations in the animator #20

Merged
merged 2 commits into from
Nov 2, 2017

Conversation

jverkoey
Copy link
Contributor

@jverkoey jverkoey commented Nov 2, 2017

A client using the animator expects that it will only add animations for the key path that was specified, but it's possible that setting the final value for a given key path can create implicit animations. We now disable implicit animations when setting the final value to the layer.

@jverkoey jverkoey requested a review from romoore November 2, 2017 18:29
@jverkoey jverkoey changed the title Disable implicit animations when adding explicit animations in the an… Disable implicit animations when adding explicit animations in the animator Nov 2, 2017
@@ -125,7 +125,10 @@ - (void)animateWithTiming:(MDMMotionTiming)timing
}
}

[CATransaction begin];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line 123: Shouldn't the completion block be attached to the new CATransaction?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The completion block is attached to the explicit animation up above.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack.


// Setting transform.rotation.z will create an implicit transform if implicit animations
// aren't disabled by the animator properly, so verify that such an animation doesn't exist:
XCTAssertNil(view.layer.animation(forKey: "transform"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe also assert that the .rotation animation is not nil?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The animator's unfortunately adding the animation with a nil key so we can't identify whether an animation was added after the fact.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe count the number of animations attached to the object before adding and after adding?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CALayer only provides animationKeys() and animationForKey. There's unfortunately no way to enumerate animations that were added with a nil key (that I know of).

@@ -125,7 +125,10 @@ - (void)animateWithTiming:(MDMMotionTiming)timing
}
}

[CATransaction begin];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack.

Jeff Verkoeyen added 2 commits November 2, 2017 15:47
…imator.

A client using the animator expects that it will only add animations for the key path that was specified, but it's possible that setting the final value for a given key path can create implicit animations. We now disable implicit animations when setting the final value to the layer.
@jverkoey jverkoey merged commit 8be151c into develop Nov 2, 2017
@jverkoey jverkoey deleted the keypaths branch November 2, 2017 20:33
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants