Skip to content

Commit

Permalink
fixed spring animation valueCount issue; removed newlines from EOF
Browse files Browse the repository at this point in the history
  • Loading branch information
crylico committed Apr 15, 2015
1 parent c0ab65c commit 11e6978
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 51 deletions.
16 changes: 0 additions & 16 deletions pop-tests/POPAnimationTests.mm
Original file line number Diff line number Diff line change
Expand Up @@ -872,22 +872,6 @@ - (void)testPlatformColorSupport
XCTAssertTrue(layerValues[0] == toValues[0] && layerValues[1] == toValues[1] && layerValues[2] == toValues[2] && layerValues[3] == toValues[3], @"unexpected last color: [r:%f g:%f b:%f a:%f]", layerValues[0], layerValues[1], layerValues[2], layerValues[3]);
}

- (void)testNSCopyingSupportPOPAnimation
{
POPAnimation *anim = [[POPAnimation alloc] _init];

configureConcreteAnimation(anim);
[self testCopyingSucceedsForConcreteAnimation:anim];
}

- (void)testNSCopyingSupportPOPPropertyAnimation
{
POPPropertyAnimation *anim = [[POPPropertyAnimation alloc] _init];

configureConcretePropertyAnimation(anim);
[self testCopyingSucceedsForConcretePropertyAnimation:anim];
}

- (void)testNSCopyingSupportPOPBasicAnimation
{
POPBasicAnimation *anim = [POPBasicAnimation animationWithPropertyNamed:@"test_property_name"];
Expand Down
50 changes: 21 additions & 29 deletions pop/POPAnimation.mm
Original file line number Diff line number Diff line change
Expand Up @@ -275,38 +275,30 @@ @implementation POPAnimation (NSCopying)

- (instancetype)copyWithZone:(NSZone *)zone
{
POPAnimation *copy = nil;
/*
* Must use [self class] instead of POPAnimation so that subclasses can call this via super.
* Even though POPAnimation and POPPropertyAnimation throw exceptions on init,
* it's safe to call it since you can only copy objects that have been successfully created.
*/
POPAnimation *copy = [[[self class] allocWithZone:zone] init];

// Must use [self class] instead of POPAnimation so that subclasses can call this via super.
// Since POPAnimation and POPPropertyAnimation are (semi-)concrete, wrap initialization in a try-catch.
// If regular initialization fails, use _init.

@try {
copy = [[[self class] allocWithZone:zone] init];
}
@catch (NSException *exception) {
copy = [[[self class] allocWithZone:zone] _init];
}
@finally {
if (copy) {

if (copy) {

copy.name = self.name;
copy.beginTime = self.beginTime;
copy.delegate = self.delegate;
copy.animationDidStartBlock = self.animationDidStartBlock;
copy.animationDidReachToValueBlock = self.animationDidReachToValueBlock;
copy.completionBlock = self.completionBlock;
copy.animationDidApplyBlock = self.animationDidApplyBlock;
copy.removedOnCompletion = self.removedOnCompletion;

copy.autoreverses = self.autoreverses;
copy.repeatCount = self.repeatCount;
copy.repeatForever = self.repeatForever;
}
copy.name = self.name;
copy.beginTime = self.beginTime;
copy.delegate = self.delegate;
copy.animationDidStartBlock = self.animationDidStartBlock;
copy.animationDidReachToValueBlock = self.animationDidReachToValueBlock;
copy.completionBlock = self.completionBlock;
copy.animationDidApplyBlock = self.animationDidApplyBlock;
copy.removedOnCompletion = self.removedOnCompletion;

return copy;
copy.autoreverses = self.autoreverses;
copy.repeatCount = self.repeatCount;
copy.repeatForever = self.repeatForever;
}

return copy;
}

@end
@end
2 changes: 1 addition & 1 deletion pop/POPBasicAnimation.mm
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,4 @@ - (instancetype)copyWithZone:(NSZone *)zone {
return copy;
}

@end
@end
2 changes: 1 addition & 1 deletion pop/POPCustomAnimation.mm
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,4 @@ - (instancetype)copyWithZone:(NSZone *)zone {
return copy;
}

@end
@end
2 changes: 1 addition & 1 deletion pop/POPDecayAnimation.mm
Original file line number Diff line number Diff line change
Expand Up @@ -201,4 +201,4 @@ - (instancetype)copyWithZone:(NSZone *)zone {
return copy;
}

@end
@end
2 changes: 1 addition & 1 deletion pop/POPPropertyAnimation.mm
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,4 @@ - (instancetype)copyWithZone:(NSZone *)zone {
return copy;
}

@end
@end
10 changes: 8 additions & 2 deletions pop/POPSpringAnimation.mm
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,13 @@ - (instancetype)copyWithZone:(NSZone *)zone {

if (copy) {

copy.velocity = POPBox(__state->originalVelocityVec, __state->valueType);
id velocity = POPBox(__state->originalVelocityVec, __state->valueType);

// If velocity never gets set, then POPBox will return nil, messing up __state->valueCount.
if (velocity) {
copy.velocity = velocity;
}

copy.springBounciness = self.springBounciness;
copy.springSpeed = self.springSpeed;
copy.dynamicsTension = self.dynamicsTension;
Expand All @@ -184,4 +190,4 @@ - (instancetype)copyWithZone:(NSZone *)zone {
return copy;
}

@end
@end

0 comments on commit 11e6978

Please sign in to comment.