The feature to preserve the view's transform after animating wouldn't work when using multiple Animations. That's because the animations.forEach loop in the animate function in ViewAnimator.swift reassigns preTransform for each animation provided to the animations array. So this only works correctly when there is only one Animation in the array. Otherwise, it would be set to the second-to-last transform from the entire animation sequence.
I noticed preTransform was set and retrieved using a computed property and using an Obj-C associated object. I didn't see how else this property could be used, so I think that just "saving" the constant at the beginning of the animate function and then restoring by capturing this constant in the UIView.animate completion handler is cleaner and safer here. Adding the preTransform property to all UIView might also interfere with clients' subclasses if they used such a property. As a bonus, this also makes the Constants.swift file unnecessary.
I added a test case for this scenario in the example app's test file, since I didn't see any tests for the pod.
The feature to preserve the view's transform after animating wouldn't work when using multiple
Animation
s. That's because theanimations.forEach
loop in theanimate
function inViewAnimator.swift
reassignspreTransform
for each animation provided to theanimations
array. So this only works correctly when there is only oneAnimation
in the array. Otherwise, it would be set to the second-to-last transform from the entire animation sequence.I noticed
preTransform
was set and retrieved using a computed property and using an Obj-C associated object. I didn't see how else this property could be used, so I think that just "saving" the constant at the beginning of theanimate
function and then restoring by capturing this constant in theUIView.animate
completion handler is cleaner and safer here. Adding thepreTransform
property to allUIView
might also interfere with clients' subclasses if they used such a property. As a bonus, this also makes theConstants.swift
file unnecessary.I added a test case for this scenario in the example app's test file, since I didn't see any tests for the pod.