Skip to content

Commit

Permalink
Added support for off One Stroke animation
Browse files Browse the repository at this point in the history
Boris-Em committed Oct 4, 2015
1 parent 7c12b23 commit ba0392c
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions Classes/BEMCheckBox.m
Original file line number Diff line number Diff line change
@@ -212,7 +212,7 @@ - (void)addOnAnimation {
switch (self.onAnimationType) {
case BEMAnimationTypeStroke: {
CABasicAnimation *animation = [self.animationManager strokeAnimationReverse:NO];

[self.onBoxLayer addAnimation:animation forKey:@"strokeEnd"];
[self.checkMarkLayer addAnimation:animation forKey:@"strokeEnd"];
}
@@ -294,7 +294,6 @@ - (void)addOffAnimation {
switch (self.offAnimationType) {
case BEMAnimationTypeStroke: {
CABasicAnimation *animation = [self.animationManager strokeAnimationReverse:YES];

[self.onBoxLayer addAnimation:animation forKey:@"strokeEnd"];
[self.checkMarkLayer addAnimation:animation forKey:@"strokeEnd"];
}
@@ -332,6 +331,30 @@ - (void)addOffAnimation {
}
return;

case BEMAnimationTypeOneStroke: {
CABasicAnimation *checkMorphAnimation = [self.animationManager morphAnimationFromPath:[self.pathManager pathForCheckMark] toPath:[self.pathManager pathForLongCheckMark]];
checkMorphAnimation.delegate = nil;
checkMorphAnimation.duration = checkMorphAnimation.duration / 6;
[self.checkMarkLayer addAnimation:checkMorphAnimation forKey:@"path"];

CABasicAnimation *checkStrokeAnimation = [self.animationManager strokeAnimationReverse:YES];
checkStrokeAnimation.delegate = nil;
checkStrokeAnimation.beginTime = CACurrentMediaTime() + checkMorphAnimation.duration;
checkStrokeAnimation.duration = checkStrokeAnimation.duration / 3;
[self.checkMarkLayer addAnimation:checkStrokeAnimation forKey:@"strokeEnd"];

__weak __typeof__(self) weakSelf = self;
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(CACurrentMediaTime() + checkMorphAnimation.duration + checkStrokeAnimation.duration * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
weakSelf.checkMarkLayer.lineCap = kCALineCapButt;
});

CABasicAnimation *boxStrokeAnimation = [self.animationManager strokeAnimationReverse:YES];
boxStrokeAnimation.beginTime = CACurrentMediaTime() + checkMorphAnimation.duration + checkStrokeAnimation.duration;
boxStrokeAnimation.duration = boxStrokeAnimation.duration / 2;
[self.onBoxLayer addAnimation:boxStrokeAnimation forKey:@"strokeEnd"];
}
return;

default: {
CABasicAnimation *animation = [self.animationManager opacityAnimationReverse:YES];

0 comments on commit ba0392c

Please sign in to comment.