From c138dfd377e728082ee33d22d8fdf354dfe1c002 Mon Sep 17 00:00:00 2001 From: luomy Date: Mon, 13 Dec 2021 12:39:23 +0800 Subject: [PATCH] fix(ios): revert scroll animation fix for ios15 --- ios/sdk/component/viewPager/HippyViewPager.mm | 38 +------------------ 1 file changed, 1 insertion(+), 37 deletions(-) diff --git a/ios/sdk/component/viewPager/HippyViewPager.mm b/ios/sdk/component/viewPager/HippyViewPager.mm index e3277a345..62fa57dd4 100644 --- a/ios/sdk/component/viewPager/HippyViewPager.mm +++ b/ios/sdk/component/viewPager/HippyViewPager.mm @@ -347,43 +347,7 @@ return; } _targetOffset = contentOffset; - - /** - * A protential bug - * It seems that adding subviews onto UIScrollView or changing property - * may cause UIScrollView to stop performing 'setContentOffset' animation in ios 15 - * still figure out why - * so we use keyframes animation to simulate 'setContentOffset' animation for now - */ - if (@available(iOS 15, *)) { - if (animated) { - static NSUInteger viewPagerSetContentoffsetFrames = 10; - static CGFloat keyFramesAnimatonDuration = .54f; - CGFloat eachXOffset = (contentOffset.x - self.contentOffset.x) / viewPagerSetContentoffsetFrames; - CGFloat eachYOffset = (contentOffset.y - self.contentOffset.y) / viewPagerSetContentoffsetFrames; - CGPoint currentOffset = self.contentOffset; - [UIView animateKeyframesWithDuration:keyFramesAnimatonDuration delay:0 options:UIViewKeyframeAnimationOptionCalculationModeLinear animations:^{ - CGFloat durationForEachKeyFrameAnimation = keyFramesAnimatonDuration / viewPagerSetContentoffsetFrames; - for (NSUInteger i = 0; i < viewPagerSetContentoffsetFrames; i++) { - CGFloat startTimeForAnimation = i * (keyFramesAnimatonDuration / viewPagerSetContentoffsetFrames); - CGPoint keyFrameContentOffset = - CGPointMake(currentOffset.x + eachXOffset * (i + 1), - currentOffset.y + eachYOffset * (i + 1)); - [UIView addKeyframeWithRelativeStartTime:startTimeForAnimation - relativeDuration:durationForEachKeyFrameAnimation - animations:^{ - [super setContentOffset:keyFrameContentOffset]; - }]; - } - } completion:NULL]; - } - else { - [super setContentOffset:contentOffset]; - } - } - else { - [super setContentOffset:contentOffset animated:animated]; - } + [super setContentOffset:contentOffset animated:animated]; } - (void)hippyBridgeDidFinishTransaction {