Skip to content

Commit 9ad2cb4

Browse files
author
Justin Martin
committed
Also ignore the KIFTouchVisualizerView
Credit to @amorde for finding this
1 parent 6b1efce commit 9ad2cb4

File tree

1 file changed

+25
-19
lines changed

1 file changed

+25
-19
lines changed

Sources/KIF/Additions/CALayer-KIFAdditions.m

+25-19
Original file line numberDiff line numberDiff line change
@@ -27,25 +27,31 @@ - (BOOL)hasAnimations
2727
{
2828
__block BOOL result = NO;
2929
[self performBlockOnDescendentLayers:^(CALayer *layer, BOOL *stop) {
30-
// explicitly exclude _UIParallaxMotionEffect as it is used in alertviews, and we don't want every alertview to be paused
31-
// explicitly exclude UITextSelectionViewCaretBlinkAnimation as it is used in textfields, and we don't want every view with textfields to be paused
32-
BOOL hasAnimation = layer.animationKeys.count != 0 && ![layer.animationKeys containsObject:@"_UIParallaxMotionEffect"] && ![layer.animationKeys containsObject:@"UITextSelectionViewCaretBlinkAnimation"];
33-
if (hasAnimation && !layer.hidden) {
34-
double currentTime = CACurrentMediaTime() * [layer KIF_absoluteSpeed];
35-
36-
[layer.animationKeys enumerateObjectsUsingBlock:^(NSString *animationKey, NSUInteger idx, BOOL *innerStop) {
37-
CAAnimation *animation = [layer animationForKey:animationKey];
38-
double beginTime = [animation beginTime];
39-
double completionTime = [animation KIF_completionTime];
40-
41-
// Ignore long running animations (> 1 minute duration)
42-
if (currentTime >= beginTime && completionTime < currentTime + 60 && currentTime < completionTime) {
43-
result = YES;
44-
*innerStop = YES;
45-
*stop = YES;
46-
}
47-
}];
48-
}
30+
// explicitly exclude _UIParallaxMotionEffect as it is used in alertviews, and we don't want every alertview to be paused
31+
// explicitly exclude UITextSelectionViewCaretBlinkAnimation as it is used in textfields, and we don't want every view with textfields to be paused
32+
BOOL hasAnimation = layer.animationKeys.count != 0 && ![layer.animationKeys containsObject:@"_UIParallaxMotionEffect"] && ![layer.animationKeys containsObject:@"UITextSelectionViewCaretBlinkAnimation"];
33+
34+
// Ignore the animation of the KIF touch visualizer circle as it does not affect any view behavior
35+
if ([NSStringFromClass(layer.delegate.class) isEqualToString:@"KIFTouchVisualizerView"]) {
36+
hasAnimation = NO;
37+
}
38+
39+
if (hasAnimation && !layer.hidden) {
40+
double currentTime = CACurrentMediaTime() * [layer KIF_absoluteSpeed];
41+
42+
[layer.animationKeys enumerateObjectsUsingBlock:^(NSString *animationKey, NSUInteger idx, BOOL *innerStop) {
43+
CAAnimation *animation = [layer animationForKey:animationKey];
44+
double beginTime = [animation beginTime];
45+
double completionTime = [animation KIF_completionTime];
46+
47+
// Ignore long running animations (> 1 minute duration)
48+
if (currentTime >= beginTime && completionTime < currentTime + 60 && currentTime < completionTime) {
49+
result = YES;
50+
*innerStop = YES;
51+
*stop = YES;
52+
}
53+
}];
54+
}
4955
}];
5056
return result;
5157
}

0 commit comments

Comments
 (0)