Ask the animator if periodic frame updates are needed

This commit is contained in:
cacaodev
2017-03-02 10:30:08 +01:00
parent c0eaf79d25
commit 42b8b3aa75
2 changed files with 13 additions and 6 deletions
+5 -6
View File
@@ -147,15 +147,13 @@ var _CPAnimationContextStack = nil,
keyTimes,
timingFunctions,
objectId;
needsPeriodicFrameUpdates,
if (!aKeyPath || !anObject || !(animation = [anObject animationForKey:aKeyPath]) || ![animation isKindOfClass:[CAAnimation class]])
return nil;
duration = [animation duration] || [self duration];
var needsPeriodicFrameUpdates = (((aKeyPath == @"frame" || aKeyPath == @"frameSize") &&
([anObject hasCustomLayoutSubviews] || [anObject hasCustomDrawRect])) || [[anObject animator] wantsPeriodicFrameUpdates]) &&
(objectId = [anObject UID]);
needsPeriodicFrameUpdates = [[anObject animator] needsPeriodicFrameUpdatesForKeyPath:aKeyPath];
if (_completionHandlerAgent)
_completionHandlerAgent.increment();
@@ -271,7 +269,6 @@ var _CPAnimationContextStack = nil,
isFrameKeyPath = (keyPath == @"frame" || keyPath == @"frameSize"),
customLayout = [aTargetView hasCustomLayoutSubviews],
customDrawing = [aTargetView hasCustomDrawRect],
needsPeriodicFrameUpdates = ((isFrameKeyPath && (customLayout || customDrawing)) || [[aTargetView animator] wantsPeriodicFrameUpdates]);
if (needsCSSAnimation)
{
@@ -305,6 +302,7 @@ var _CPAnimationContextStack = nil,
var completionFunction = (anIndex == 0) ? anAction.completion : null;
var property = [aDict objectForKey:@"property"],
getter = [aDict objectForKey:@"value"];
needsPeriodicFrameUpdates = [[targetView animator] needsPeriodicFrameUpdatesForKeyPath:keyPath],
cssAnimation.addPropertyAnimation(property, getter, duration, anAction.keytimes, anAction.values, timingFunctions, completionFunction);
}];
@@ -348,7 +346,8 @@ var _CPAnimationContextStack = nil,
};
}
[self getAnimations:cssAnimations getTimers:timers forView:aSubview usingAction:action rootView:rootView cssAnimate:!customLayout];
var animate = !needsPeriodicFrameUpdates;
[self getAnimations:cssAnimations getTimers:timers usingAction:action cssAnimate:animate];
}];
}
}
+8
View File
@@ -87,6 +87,14 @@
}
}
- (BOOL)needsPeriodicFrameUpdatesForKeyPath:(CPString)aKeyPath
{
return ((aKeyPath == @"frame" || aKeyPath == @"frameSize") &&
(([_target hasCustomLayoutSubviews] && ![_target implementsSelector:@selector(frameRectOfView:inSuperviewSize:)])
|| [_target hasCustomDrawRect]))
|| [self wantsPeriodicFrameUpdates];
}
@end
var transformFrameToWidth = function(start, current)