Skip to content

Commit

Permalink
* [ios] refix transform's parse bug about translate
Browse files Browse the repository at this point in the history
close apache#898, close apache#903, close apache#907, close apache#883

* [ios] fix parse translateY

* [ios] fix transition transform value incorrect
  • Loading branch information
doumafang authored and acton393 committed Nov 23, 2017
1 parent caa5c58 commit 0535ac6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 27 deletions.
35 changes: 15 additions & 20 deletions ios/sdk/WeexSDK/Sources/Component/WXTransform.m
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,6 @@ - (void)parseTransformOrigin:(NSString *)cssValue
}
}
}

_originX = [WXLength lengthWithFloat:originX type:typeX];
_originY = [WXLength lengthWithFloat:originY type:typeY];
}
Expand Down Expand Up @@ -347,6 +346,12 @@ - (void)parsePerspective:(NSArray *)value
}

- (void)parseTranslate:(NSArray *)value
{
[self parseTranslatex:@[value[0]]];
[self parseTranslatey:@[value[1]]];
}

- (void)parseTranslatex:(NSArray *)value
{
WXLength *translateX;
double x = [value[0] doubleValue];
Expand All @@ -356,30 +361,20 @@ - (void)parseTranslate:(NSArray *)value
x = WXPixelScale(x, self.weexInstance.pixelScaleFactor);
translateX = [WXLength lengthWithFloat:x type:WXLengthTypeFixed];
}

WXLength *translateY;
if (value.count > 1) {
double y = [value[1] doubleValue];
if ([value[1] hasSuffix:@"%"]) {
translateY = [WXLength lengthWithFloat:y type:WXLengthTypePercent];
} else {
y = WXPixelScale(y, self.weexInstance.pixelScaleFactor);
translateY = [WXLength lengthWithFloat:y type:WXLengthTypeFixed];
}
}

_translateX = translateX;
_translateY = translateY;
}

- (void)parseTranslatex:(NSArray *)value
{
[self parseTranslate:@[value[0], @"0"]];
}

- (void)parseTranslatey:(NSArray *)value
{
[self parseTranslate:@[@"0", value[0]]];
WXLength *translateY;
double y = [value[0] doubleValue];
if ([value[0] hasSuffix:@"%"]) {
translateY = [WXLength lengthWithFloat:y type:WXLengthTypePercent];
} else {
y = WXPixelScale(y, self.weexInstance.pixelScaleFactor);
translateY = [WXLength lengthWithFloat:y type:WXLengthTypeFixed];
}
_translateY = translateY;
}

- (void)parseScale:(NSArray *)value
Expand Down
13 changes: 6 additions & 7 deletions ios/sdk/WeexSDK/Sources/Module/WXTransition.m
Original file line number Diff line number Diff line change
Expand Up @@ -243,21 +243,20 @@ - (void)_dealTransitionWithProperty:(NSString *)singleProperty styles:(NSDiction
info.perValue = @([info.toValue floatValue] - [info.fromValue floatValue]);
[_propertyArray addObject:info];
}

if (wxTransform.translateX && [wxTransform.translateX floatValue] !=[oldTransform.translateX floatValue]) {
WXTransitionInfo *info = [WXTransitionInfo new];
info.propertyName = @"transform.translation.x";
info.fromValue = @([oldTransform.translateX valueForMaximum:_targetComponent.view.bounds.size.width]);
info.toValue = @([wxTransform.translateX valueForMaximum:_targetComponent.view.bounds.size.width]);
info.perValue = @([info.toValue floatValue] - [info.fromValue floatValue]);
info.fromValue = @([oldTransform.translateX floatValue]);
info.toValue = @([wxTransform.translateX floatValue]);
info.perValue = @([wxTransform.translateX floatValue] - [oldTransform.translateX floatValue]);
[_propertyArray addObject:info];
}
if (wxTransform.translateY && [wxTransform.translateY floatValue] !=[oldTransform.translateY floatValue]) {
WXTransitionInfo *info = [WXTransitionInfo new];
info.propertyName = @"transform.translation.y";
info.fromValue = @([oldTransform.translateY valueForMaximum:_targetComponent.view.bounds.size.height]);
info.toValue = @([wxTransform.translateY valueForMaximum:_targetComponent.view.bounds.size.height]);
info.perValue = @([info.toValue floatValue] - [info.fromValue floatValue]);
info.fromValue = @([oldTransform.translateY floatValue]);
info.toValue = @([wxTransform.translateY floatValue]);
info.perValue = @([wxTransform.translateY floatValue] - [oldTransform.translateY floatValue]);
[_propertyArray addObject:info];
}
_targetComponent->_transform = wxTransform;
Expand Down

0 comments on commit 0535ac6

Please sign in to comment.