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

[WEEX-124][iOS]Transform's parse problem about translate #883

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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