Skip to content

Commit

Permalink
* [ios] fix issue transform does not work while initialized.
Browse files Browse the repository at this point in the history
  • Loading branch information
cxfeng1 committed Sep 4, 2016
1 parent 2191090 commit c36f1bf
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 10 deletions.
2 changes: 2 additions & 0 deletions ios/sdk/WeexSDK/Sources/Component/WXCellComponent.m
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ - (void)dealloc

- (void)_frameDidCalculated:(BOOL)isChanged
{
[super _frameDidCalculated:isChanged];

if (isChanged) {
[self.list cellDidLayout:self];
}
Expand Down
2 changes: 2 additions & 0 deletions ios/sdk/WeexSDK/Sources/Component/WXListComponent.m
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ - (instancetype)initWithRef:(NSString *)ref type:(NSString *)type styles:(NSDict

- (void)_frameDidCalculated:(BOOL)isChanged
{
[super _frameDidCalculated:isChanged];

if (isChanged) {
[self.list headerDidLayout:self];
}
Expand Down
1 change: 1 addition & 0 deletions ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ - (void)syncTextStorageForView

- (void)_frameDidCalculated:(BOOL)isChanged
{
[super _frameDidCalculated:isChanged];
[self syncTextStorageForView];
}

Expand Down
23 changes: 13 additions & 10 deletions ios/sdk/WeexSDK/Sources/Layout/WXComponent+Layout.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#import "WXTransform.h"
#import "WXAssert.h"
#import "WXComponent_internal.h"
#import "WXSDKInstance_private.h"

@implementation WXComponent (Layout)

Expand Down Expand Up @@ -96,6 +97,18 @@ - (NSUInteger)_childrenCountForLayout
- (void)_frameDidCalculated:(BOOL)isChanged
{
WXAssertComponentThread();

if ([self isViewLoaded] && isChanged && [self isViewFrameSyncWithCalculated]) {

[self.weexInstance.componentManager _addUITask:^{
self.view.frame = _calculatedFrame;
if (_transform) {
_layer.transform = [[WXTransform new] getTransform:_transform withView:_view withOrigin:_transformOrigin];
}

[_layer setNeedsDisplay];
}];
}
}

- (void)_calculateFrameWithSuperAbsolutePosition:(CGPoint)superAbsolutePosition
Expand Down Expand Up @@ -159,16 +172,6 @@ - (void)_layoutDidFinish
{
WXAssertMainThread();

if ([self isViewLoaded] && !CGRectEqualToRect(_calculatedFrame, self.view.frame)
&& [self isViewFrameSyncWithCalculated]) {
self.view.frame = _calculatedFrame;
// transform does not belong to layout, move it to other place hopefully
if (_transform) {
_layer.transform = [[WXTransform new] getTransform:_transform withView:self.view withOrigin:_transformOrigin];
}
[_layer setNeedsDisplay];
}

if (_positionType == WXPositionTypeSticky) {
[self.ancestorScroller adjustSticky];
}
Expand Down
5 changes: 5 additions & 0 deletions ios/sdk/WeexSDK/Sources/Model/WXComponent.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#import "WXAssert.h"
#import "WXThreadSafeMutableDictionary.h"
#import "WXThreadSafeMutableArray.h"
#import "WXTransform.h"
#import <pthread/pthread.h>

#pragma clang diagnostic ignored "-Wincomplete-implementation"
Expand Down Expand Up @@ -187,6 +188,10 @@ - (UIView *)view
_view.backgroundColor = _backgroundColor;
}

if (_transform) {
_layer.transform = [[WXTransform new] getTransform:_transform withView:_view withOrigin:_transformOrigin];
}

_view.wx_component = self;
_view.wx_ref = self.ref;
_layer.wx_component = self;
Expand Down

0 comments on commit c36f1bf

Please sign in to comment.