Skip to content
This repository was archived by the owner on Jun 3, 2021. It is now read-only.

Commit d7620e0

Browse files
authored
[BUG] 修正动画处理时逐帧模拟的计算误差及逻辑问题,详见 #2347
1 parent 5fec7c5 commit d7620e0

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

ios/sdk/WeexSDK/Sources/Module/WXTransition.mm

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,10 +317,15 @@ - (void)_calculatetransitionProcessingStyle
317317
if (_propertyArray.count == 0) {
318318
return;
319319
}
320-
double per = 1000 * (_transitionCount + 1 ) / (60 * _transitionDuration);//linear
320+
321+
// Bugfix: https://github.com/apache/incubator-weex/issues/2347
322+
NSUInteger frameCount = _transitionDuration * 60 / 1000;
323+
NSUInteger currentFrame = _transitionCount + 1;
324+
double per = (double)currentFrame / frameCount; //linear
321325
if (![[NSString stringWithFormat:@"%@",_transitionTimingFunction] isEqualToString: kCAMediaTimingFunctionLinear]) {
322-
per = [self solveWithx:((_transitionCount+2)*16)/_transitionDuration epsilon:SOLVE_EPS(_transitionDuration)];
326+
per = [self solveWithx:per epsilon:SOLVE_EPS(_transitionDuration)];
323327
}
328+
324329
NSString *transformString = [NSString string];
325330
for (WXTransitionInfo *info in _propertyArray) {
326331
if ([info.propertyName isEqualToString:@"backgroundColor"]) {

0 commit comments

Comments
 (0)