This commit is contained in:
Ali 2022-05-27 22:33:26 +04:00
parent f192fbf16b
commit e69e0a33dd
5 changed files with 51 additions and 2 deletions

View File

@ -807,6 +807,12 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture
}
public func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) {
if #available(iOS 15.0, *) {
if let scrollDisplayLink = self.scroller.value(forKey: "_scrollHeartbeat") as? CADisplayLink {
let _ = scrollDisplayLink
}
}
self.isDragging = false
if decelerate {
self.lastContentOffsetTimestamp = CACurrentMediaTime()
@ -886,6 +892,7 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture
public func scrollViewDidScroll(_ scrollView: UIScrollView) {
self.updateScrollViewDidScroll(scrollView, synchronous: self.defaultToSynchronousTransactionWhileScrolling)
scrollView.fixScrollDisplayLink()
}
private var generalAccumulatedDeltaY: CGFloat = 0.0

View File

@ -48,3 +48,9 @@ void applyKeyboardAutocorrection(UITextView * _Nonnull textView);
@property (nonatomic, copy) UIInterfaceOrientationMask (^ _Nullable supportedOrientations)(void);
@end
@interface UIScrollView (FrameRateRangeOverride)
- (void)fixScrollDisplayLink;
@end

View File

@ -43,6 +43,7 @@ static const void *inputAccessoryHeightProviderKey = &inputAccessoryHeightProvid
static const void *interactiveTransitionGestureRecognizerTestKey = &interactiveTransitionGestureRecognizerTestKey;
static const void *UIViewControllerHintWillBePresentedInPreviewingContextKey = &UIViewControllerHintWillBePresentedInPreviewingContextKey;
static const void *disablesInteractiveModalDismissKey = &disablesInteractiveModalDismissKey;
static const void *forceFullRefreshRateKey = &forceFullRefreshRateKey;
static bool notyfyingShiftState = false;
@ -99,14 +100,41 @@ static bool notyfyingShiftState = false;
@implementation CADisplayLink (FrameRateRangeOverride)
- (void)_65087dc8_setPreferredFrameRateRange:(CAFrameRateRange)range API_AVAILABLE(ios(15.0)) {
float maxFps = [UIScreen mainScreen].maximumFramesPerSecond;
range = CAFrameRateRangeMake(maxFps, maxFps, maxFps);
if ([self associatedObjectForKey:forceFullRefreshRateKey] != nil) {
float maxFps = [UIScreen mainScreen].maximumFramesPerSecond;
range = CAFrameRateRangeMake(maxFps, maxFps, maxFps);
}
[self _65087dc8_setPreferredFrameRateRange:range];
}
@end
@implementation UIScrollView (FrameRateRangeOverride)
- (void)fixScrollDisplayLink {
static NSString *scrollHeartbeatKey = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
scrollHeartbeatKey = [NSString stringWithFormat:@"_%@", @"scrollHeartbeat"];
});
id value = [self valueForKey:scrollHeartbeatKey];
if ([value isKindOfClass:[CADisplayLink class]]) {
CADisplayLink *displayLink = (CADisplayLink *)value;
if ([displayLink associatedObjectForKey:forceFullRefreshRateKey] == nil) {
[displayLink setAssociatedObject:@true forKey:forceFullRefreshRateKey];
if (@available(iOS 15.0, *)) {
float maxFps = [UIScreen mainScreen].maximumFramesPerSecond;
[displayLink setPreferredFrameRateRange:CAFrameRateRangeMake(maxFps, maxFps, maxFps)];
}
}
}
}
@end
@implementation UIViewController (Navigation)
+ (void)load

View File

@ -216,6 +216,10 @@
animationWithKeyPath:event];
theAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
theAnimation.fromValue = [[self presentationLayer] valueForKey:event];
if (@available(iOS 15.0, *)) {
float maxFps = UIScreen.mainScreen.maximumFramesPerSecond;
[theAnimation setPreferredFrameRateRange:CAFrameRateRangeMake(maxFps, maxFps, maxFps)];
}
return theAnimation;
}
return [super actionForKey:event];

View File

@ -363,6 +363,10 @@ static NSString * const kCompContainerAnimationKey = @"play";
} else {
NSTimeInterval duration = (ABS(toEndFrame.floatValue - fromStartFrame.floatValue) / _sceneModel.framerate.floatValue);
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"currentFrame"];
if (@available(iOS 15.0, *)) {
float maxFps = UIScreen.mainScreen.maximumFramesPerSecond;
[animation setPreferredFrameRateRange:CAFrameRateRangeMake(maxFps, maxFps, maxFps)];
}
animation.speed = _animationSpeed;
animation.fromValue = fromStartFrame;
animation.toValue = toEndFrame;