Repository: incubator-weex
Updated Branches:
  refs/heads/master 24214546f -> d7fb0797f


[WEEX-158] [iOS] Fix transition's height may show incorrect when selected

XianyuApp's developper found this bug in a detailed case.In a selection page, 
we found that when multiple choices will trigger a problem, identified, to 
determine the reason because the data accuracy does not meet the demand.

After fix  with solution by replacing float to double. it is fixed.

So, we fix this bug

[WEEX-158] [iOS] Fix transition's height may show incorrect when selected

XianyuApp's developper found this bug in a detailed case.In a selection page, 
we found that when multiple choices will trigger a problem, identified, to 
determine the reason because the data accuracy does not meet the demand.

After fix with solution by replacing float to double. it is fixed.

So, we fix this bug and update our vue demo.

[WEEX-158] [iOS] Fix transition's height may show incorrect when selected

Reduce memory risk and avoid excessive memory usage.


Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/d7fb0797
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/d7fb0797
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/d7fb0797

Branch: refs/heads/master
Commit: d7fb0797f1dd3f2add34d710ffbf1eb7d5411683
Parents: 2421454
Author: doumafang <doumaf...@gmail.com>
Authored: Fri Dec 1 19:36:09 2017 +0800
Committer: acton393 <zhangxing610...@gmail.com>
Committed: Wed Dec 6 21:31:35 2017 +0800

----------------------------------------------------------------------
 examples/vue/transition.vue                     |  57 ++++--
 .../Sources/Component/WXComponent_internal.h    |   2 -
 ios/sdk/WeexSDK/Sources/Model/WXComponent.m     |  32 ++--
 .../WeexSDK/Sources/Module/WXAnimationModule.m  |   8 +-
 ios/sdk/WeexSDK/Sources/Module/WXTransition.h   |   2 +-
 ios/sdk/WeexSDK/Sources/Module/WXTransition.m   | 179 +++++++++----------
 6 files changed, 144 insertions(+), 136 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/d7fb0797/examples/vue/transition.vue
----------------------------------------------------------------------
diff --git a/examples/vue/transition.vue b/examples/vue/transition.vue
index dbdf38a..abcf830 100644
--- a/examples/vue/transition.vue
+++ b/examples/vue/transition.vue
@@ -13,6 +13,7 @@
 <script>
     export default {
         created () {
+            this.datasource = 
['width+height','backgroundColor','opactity','transform/translateX','transform/translateY','transform/scaleX','transform/scaleY','transform/rotate']
             this.panels = this.randomfn()
         },
         data () {
@@ -24,20 +25,55 @@
             change (i) {
                 const item = this.panels[i]
                 if (item) {
-                    item.height = item.height === 200 ? 400 : 200
-                    item.width = item.width === 330 ? 660 : 330
-                    item.bgc = item.bgc ===  '#69BE96' ? '#72B8DF':'#69BE96'
-                    item.opacity = item.opacity === 1.0 ? 0.6 : 1.0
-                    item.transform = item.transform === 
'translateX(20px)'?'translateX(40px)':'translateX(20px)'
+
+                    if(i==0)
+                    {
+                        item.height = item.height === 330 ? 200 : 330
+                        item.width = item.width === 350 ? 730 : 350
+                    }
+                    if(i==1)
+                    {
+                        item.bgc = item.bgc ===  '#69BE96' ? 'red':'#69BE96'
+                    }
+                    if(i==2)
+                    {
+                        item.opacity = item.opacity === 1.0 ? 0.6 : 1.0
+                    }
+                    if(i==3)
+                    {
+                        item.bgc = item.bgc ===  '#69BE96' ? 
'#72B8DF':'#69BE96'
+                        item.transform = item.transform === 
'translateX(200px)'?'translateX(0px)':'translateX(200px)'
+                    }
+                    if(i==4)
+                    {
+                        item.bgc = item.bgc ===  '#69BE96' ? 
'#72B8DF':'#69BE96'
+                        item.transform = item.transform === 
'translateY(-150px)'?'translateY(0px)':'translateY(-150px)'
+                    }
+                    if(i==5)
+                    {
+                       item.bgc = item.bgc ===  '#69BE96' ? '#72B8DF':'#69BE96'
+                       item.transform = item.transform === 
'scaleX(0.5)'?'scaleX(1)':'scaleX(0.5)'
+                    }
+                    if(i==6)
+                    {
+                       item.bgc = item.bgc ===  '#69BE96' ? '#72B8DF':'#69BE96'
+                       item.transform = item.transform === 
'scaleY(0.5)'?'scaleY(1)':'scaleY(0.5)'
+                    }
+                    if(i==7)
+                    {
+                       item.bgc = item.bgc ===  '#69BE96' ? '#72B8DF':'#69BE96'
+                       item.transform = item.transform === 
'rotate(40deg)'?'rotate(0deg)':'rotate(40deg)'
+                    }
+                    
                 }
             },
             randomfn () {
                 let ary = [];
-                for(let i = 1; i<= 10; i++) {
-                    ary.push({label: i ,height: 200 , width:730, 
bgc:'#69BE96',opacity:1})
+                for(let i = 0; i<= 7; i++) {
+                    ary.push({label: this.datasource[i] ,height: 200 , 
width:730, bgc:'#69BE96',opacity:1,right:20})
                 }
                 return ary;
-            }
+            },
         }
     }
 </script>
@@ -51,10 +87,10 @@
         border: solid;
         border-radius: 10px; 
           
-        transition-property: width,height,backgroundColor,opacity,transform;  
+        transition-property: 
right,left,top,bottom,width,height,backgroundColor,opacity,transform;
         transition-duration: 0.5s; 
         transition-delay: 0s;
-        transition-timing-function: cubic-bezier(0.25, 0.1, 0.25, 1.0); 
+        transition-timing-function: cubic-bezier(0.58, 0.1, 0.42, 1.0); 
     }
     .cell{
         background-color:white;
@@ -70,6 +106,5 @@
     }
     .list{
         background-color:white;
-        flex-direction: row;
     }
 </style>

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/d7fb0797/ios/sdk/WeexSDK/Sources/Component/WXComponent_internal.h
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Component/WXComponent_internal.h 
b/ios/sdk/WeexSDK/Sources/Component/WXComponent_internal.h
index dc9772b..eddbfe7 100644
--- a/ios/sdk/WeexSDK/Sources/Component/WXComponent_internal.h
+++ b/ios/sdk/WeexSDK/Sources/Component/WXComponent_internal.h
@@ -202,8 +202,6 @@ typedef id (^WXDataBindingBlock)(NSDictionary *data, BOOL 
*needUpdate);
 /// @name Private Methods
 ///--------------------------------------
 
-- (void)_handleLayoutAnimationWithStyles:(NSDictionary *)styles;
-
 - (void)_modifyStyles:(NSDictionary *)styles;
 
 - (void)_transitionUpdateViewProperty:(NSDictionary *)styles;

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/d7fb0797/ios/sdk/WeexSDK/Sources/Model/WXComponent.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Model/WXComponent.m 
b/ios/sdk/WeexSDK/Sources/Model/WXComponent.m
index a924176..aaf04d1 100644
--- a/ios/sdk/WeexSDK/Sources/Model/WXComponent.m
+++ b/ios/sdk/WeexSDK/Sources/Model/WXComponent.m
@@ -97,8 +97,11 @@
         _accessibilityHintContent = nil;
         
         _async = NO;
-        _transition = [[WXTransition alloc]initWithStyles:styles];
         
+        if (styles[kWXTransitionProperty]) {
+            _transition = [[WXTransition alloc]initWithStyles:styles];
+        }
+
         //TODO set indicator style 
         if ([type isEqualToString:@"indicator"]) {
             _styles[@"position"] = @"absolute";
@@ -566,39 +569,29 @@
 #pragma mark Updating
 - (void)_updateStylesOnComponentThread:(NSDictionary *)styles 
resetStyles:(NSMutableArray *)resetStyles isUpdateStyles:(BOOL)isUpdateStyles
 {
-    if ([self _isPropertyTransitionStyles:styles]) {
-        [_transition _handleTransitionWithStyles:styles withTarget:self];
+    BOOL isTransitionTag = _transition ? [self _isTransitionTag:styles] : NO;
+    if (isTransitionTag) {
+        [_transition _handleTransitionWithStyles:styles 
resetStyles:resetStyles target:self];
     } else {
         styles = [self parseStyles:styles];
         [self _updateCSSNodeStyles:styles];
+        [self _resetCSSNodeStyles:resetStyles];
     }
-    
     if (isUpdateStyles) {
         [self _modifyStyles:styles];
     }
-    [self _resetCSSNodeStyles:resetStyles];
 }
 
-- (BOOL)_isPropertyTransitionStyles:(NSDictionary *)styles
+- (BOOL)_isTransitionTag:(NSDictionary *)styles
 {
     BOOL yesOrNo = false;
     if (_transition.transitionOptions != WXTransitionOptionsNone) {
-        if ((_transition.transitionOptions & WXTransitionOptionsWidth 
&&styles[@"width"])
-            ||(_transition.transitionOptions & WXTransitionOptionsHeight 
&&styles[@"height"])
-            ||(_transition.transitionOptions & WXTransitionOptionsRight 
&&styles[@"right"])
-            ||(_transition.transitionOptions & WXTransitionOptionsLeft 
&&styles[@"left"])
-            ||(_transition.transitionOptions & WXTransitionOptionsBottom 
&&styles[@"bottom"])
-            ||(_transition.transitionOptions & WXTransitionOptionsTop 
&&styles[@"top"])
-            ||(_transition.transitionOptions & 
WXTransitionOptionsBackgroundColor &&styles[@"backgroundColor"])
-            ||(_transition.transitionOptions & WXTransitionOptionsTransform 
&&styles[@"transform"])
-            ||(_transition.transitionOptions & WXTransitionOptionsOpacity 
&&styles[@"opacity"])) {
-            yesOrNo = true;
-        }
+        yesOrNo = true;
     }
     return yesOrNo;
 }
 
-- (BOOL)_isPropertyAnimationStyles:(NSDictionary *)styles
+- (BOOL)_isTransitionOnMainThreadStyles:(NSDictionary *)styles
 {
     BOOL yesOrNo = false;
     if (_transition.transitionOptions != WXTransitionOptionsNone) {
@@ -642,12 +635,11 @@
 - (void)_updateStylesOnMainThread:(NSDictionary *)styles 
resetStyles:(NSMutableArray *)resetStyles
 {
     WXAssertMainThread();
-    if (![self _isPropertyAnimationStyles:styles]) {
+    if (![self _isTransitionOnMainThreadStyles:styles]) {
         [self _updateViewStyles:styles];
     } else {
         [self _transitionUpdateViewProperty:styles];
     }
-    
     [self _resetStyles:resetStyles];
     [self _handleBorders:styles isUpdating:YES];
     [self updateStyles:styles];

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/d7fb0797/ios/sdk/WeexSDK/Sources/Module/WXAnimationModule.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Module/WXAnimationModule.m 
b/ios/sdk/WeexSDK/Sources/Module/WXAnimationModule.m
index 962763b..46ff00b 100644
--- a/ios/sdk/WeexSDK/Sources/Module/WXAnimationModule.m
+++ b/ios/sdk/WeexSDK/Sources/Module/WXAnimationModule.m
@@ -273,7 +273,7 @@ WX_EXPORT_METHOD(@selector(transition:args:callback:))
             [infos addObject:info];
         } else if ([property isEqualToString:@"width"]) {
             if (_needLayout) {
-                [self animationWithLayoutAnimationTarget:target 
handleProperty:property withDic:args];
+                [self animationWithTransitionTarget:target 
handleProperty:property withDic:args];
             }
             else
             {
@@ -286,7 +286,7 @@ WX_EXPORT_METHOD(@selector(transition:args:callback:))
             }
         } else if ([property isEqualToString:@"height"]) {
             if (_needLayout) {
-                [self animationWithLayoutAnimationTarget:target 
handleProperty:property withDic:args];
+                [self animationWithTransitionTarget:target 
handleProperty:property withDic:args];
             }
             else
             {
@@ -302,7 +302,7 @@ WX_EXPORT_METHOD(@selector(transition:args:callback:))
     return infos;
 }
 
-- (void)animationWithLayoutAnimationTarget:(WXComponent *)target 
handleProperty:(NSString *)property withDic:(NSDictionary *)args
+- (void)animationWithTransitionTarget:(WXComponent *)target 
handleProperty:(NSString *)property withDic:(NSDictionary *)args
 {
     NSDictionary *styles = args[@"styles"];
     _transition.addStyles = [NSMutableDictionary 
dictionaryWithDictionary:styles];
@@ -361,7 +361,7 @@ WX_EXPORT_METHOD(@selector(transition:args:callback:))
     [CATransaction commit];
     if (_needLayout) {
         WXPerformBlockOnComponentThread(^{
-            [_transition _handleTransitionWithStyles:_transition.addStyles 
withTarget:targetComponent];
+            [_transition _handleTransitionWithStyles:_transition.addStyles 
resetStyles:nil target:targetComponent];
         });
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/d7fb0797/ios/sdk/WeexSDK/Sources/Module/WXTransition.h
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Module/WXTransition.h 
b/ios/sdk/WeexSDK/Sources/Module/WXTransition.h
index b822718..b832e3e 100644
--- a/ios/sdk/WeexSDK/Sources/Module/WXTransition.h
+++ b/ios/sdk/WeexSDK/Sources/Module/WXTransition.h
@@ -51,7 +51,7 @@ typedef NS_OPTIONS(NSUInteger, WXTransitionOptions) {
 @property(nonatomic,strong) NSMutableArray *propertyArray;
 @property(nonatomic,assign) WXTransitionOptions transitionOptions;
 - (instancetype) initWithStyles:(NSDictionary *)styles;
-- (void)_handleTransitionWithStyles:(NSDictionary *)styles 
withTarget:(WXComponent *)targetComponent;
+- (void)_handleTransitionWithStyles:(NSDictionary *)styles 
resetStyles:(NSMutableArray *)resetStyles  target:(WXComponent 
*)targetComponent;
 @end
 
 

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/d7fb0797/ios/sdk/WeexSDK/Sources/Module/WXTransition.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Module/WXTransition.m 
b/ios/sdk/WeexSDK/Sources/Module/WXTransition.m
index 9855f58..03cbc62 100644
--- a/ios/sdk/WeexSDK/Sources/Module/WXTransition.m
+++ b/ios/sdk/WeexSDK/Sources/Module/WXTransition.m
@@ -47,12 +47,12 @@
     double by;
     double cy;
     
-    float _layoutAnimationDuration;
-    float _layoutAnimationDelay;
-    NSUInteger _layoutAnimationCount;
+    float _transitionDuration;
+    float _transitionDelay;
+    NSUInteger _transitionCount;
     
-    CAMediaTimingFunction *_layoutAnimationTimingFunction;
-    CADisplayLink *_layoutAnimationDisplayLink;
+    CAMediaTimingFunction *_transitionTimingFunction;
+    CADisplayLink *_transitionDisplayLink;
 
     NSMutableDictionary *_toStyles;
     NSMutableDictionary *_fromStyles;
@@ -68,34 +68,28 @@
 {
     if (self = [super init]) {
         NSString *property = styles[kWXTransitionProperty];
-        if (property) {
-            _transitionOptions |= [property containsString:@"width"]? 
WXTransitionOptionsWidth:0;
-            _transitionOptions |= [property containsString:@"height"]? 
WXTransitionOptionsHeight:0;
-            _transitionOptions |= [property containsString:@"right"]? 
WXTransitionOptionsRight:0;
-            _transitionOptions |= [property containsString:@"left"]? 
WXTransitionOptionsLeft:0;
-            _transitionOptions |= [property containsString:@"bottom"]? 
WXTransitionOptionsBottom:0;
-            _transitionOptions |= [property containsString:@"top"]? 
WXTransitionOptionsTop:0;
-            _transitionOptions |= [property 
containsString:@"backgroundColor"]? WXTransitionOptionsBackgroundColor:0;
-            _transitionOptions |= [property containsString:@"transform"]? 
WXTransitionOptionsTransform:0;
-            _transitionOptions |= [property containsString:@"opacity"]? 
WXTransitionOptionsOpacity:0;
-        }
-        else
-        {
-            return self;
-        }
+        _transitionOptions |= [property containsString:@"width"]? 
WXTransitionOptionsWidth:0;
+        _transitionOptions |= [property containsString:@"height"]? 
WXTransitionOptionsHeight:0;
+        _transitionOptions |= [property containsString:@"right"]? 
WXTransitionOptionsRight:0;
+        _transitionOptions |= [property containsString:@"left"]? 
WXTransitionOptionsLeft:0;
+        _transitionOptions |= [property containsString:@"bottom"]? 
WXTransitionOptionsBottom:0;
+        _transitionOptions |= [property containsString:@"top"]? 
WXTransitionOptionsTop:0;
+        _transitionOptions |= [property containsString:@"backgroundColor"]? 
WXTransitionOptionsBackgroundColor:0;
+        _transitionOptions |= [property containsString:@"transform"]? 
WXTransitionOptionsTransform:0;
+        _transitionOptions |= [property containsString:@"opacity"]? 
WXTransitionOptionsOpacity:0;
     }
     return self;
 }
 
 #pragma mark - HandleStyle
-- (void)_handleTransitionWithStyles:(NSDictionary *)styles 
withTarget:(WXComponent *)targetComponent
+- (void)_handleTransitionWithStyles:(NSDictionary *)styles 
resetStyles:(NSMutableArray *)resetStyles target:(WXComponent *)targetComponent
 {
-    if ([self _isLayoutAnimationRunning]) {
+    if ([self _isTransitionRunning]) {
         [self _rollBackTransitionWithStyles:styles];
     }
     else
     {
-        [self _suspendLayoutAnimationDisplayLink];
+        [self _suspendTransitionDisplayLink];
     }
     
     _targetComponent = targetComponent;
@@ -110,67 +104,49 @@
     _toStyles = [NSMutableDictionary dictionaryWithDictionary:_fromStyles];
     [_toStyles addEntriesFromDictionary:_addStyles];
     
-    _layoutAnimationDuration = _fromStyles[kWXTransitionDuration] ? [WXConvert 
CGFloat:_fromStyles[kWXTransitionDuration]] : 0;
-    _layoutAnimationDelay = _fromStyles[kWXTransitionDelay] ? [WXConvert 
CGFloat:_fromStyles[kWXTransitionDelay]] : 0;
-    _layoutAnimationTimingFunction = [WXConvert 
CAMediaTimingFunction:_fromStyles[kWXTransitionTimingFunction]];
+    _transitionDuration = _fromStyles[kWXTransitionDuration] ? [WXConvert 
CGFloat:_fromStyles[kWXTransitionDuration]] : 0;
+    _transitionDelay = _fromStyles[kWXTransitionDelay] ? [WXConvert 
CGFloat:_fromStyles[kWXTransitionDelay]] : 0;
+    _transitionTimingFunction = [WXConvert 
CAMediaTimingFunction:_fromStyles[kWXTransitionTimingFunction]];
     
-    if (_layoutAnimationDuration == 0 ) {
+    if (_transitionDuration == 0 ) {
         [targetComponent _updateCSSNodeStyles:styles];
+        [targetComponent _resetCSSNodeStyles:resetStyles];
         WXPerformBlockOnMainThread(^{
             [targetComponent _updateViewStyles:styles];
         });
         return;
     }
     
-    if (![[NSString stringWithFormat:@"%@",_layoutAnimationTimingFunction] 
isEqualToString: kCAMediaTimingFunctionLinear]) {
+    if (![[NSString stringWithFormat:@"%@",_transitionTimingFunction] 
isEqualToString: kCAMediaTimingFunctionLinear]) {
         float vec[4] = {0.};
-        [_layoutAnimationTimingFunction getControlPointAtIndex:1 
values:&vec[0]];
-        [_layoutAnimationTimingFunction getControlPointAtIndex:2 
values:&vec[2]];
+        [_transitionTimingFunction getControlPointAtIndex:1 values:&vec[0]];
+        [_transitionTimingFunction getControlPointAtIndex:2 values:&vec[2]];
         [self unitBezierp1x:vec[0] p1y:vec[1] p2x:vec[2] p2y:vec[3]];
     }
     
-    NSString *layoutAnimationProperty = _fromStyles[kWXTransitionProperty];
-    [self _resloveTransitionProperty:layoutAnimationProperty 
withStyles:styles];
-    [self performSelector:@selector(_startLayoutAnimationDisplayLink) 
withObject:self afterDelay:_layoutAnimationDelay/1000];
+    NSString *transitionProperty = _fromStyles[kWXTransitionProperty];
+    [self _resloveTransitionProperty:transitionProperty withStyles:styles];
+    [self performSelector:@selector(_startTransitionDisplayLink) 
withObject:self afterDelay:_transitionDelay/1000];
 }
 
 - (void)_rollBackTransitionWithStyles:(NSDictionary *)styles
 {
-    _layoutAnimationDuration = _layoutAnimationCount * 1000 / 60;
-    _layoutAnimationCount = 0;
+    _transitionDuration = _transitionCount * 1000 / 60;
+    _transitionCount = 0;
     _propertyArray = nil;
 }
 
 - (void)_resloveTransitionProperty:(NSString *)propertyNames 
withStyles:(NSDictionary *)styles
 {
-    NSArray *array = 
@[@"width",@"height",@"top",@"bottom",@"right",@"left",@"opacity"];
-    for (NSString *propertyName in array) {
-        if ([propertyNames containsString:propertyName]) {
-            [self _judgeProperty:propertyName];
-        }
+    if (styles.count == 0) {
+        return;
     }
-    
-    NSArray *animationModuleArray = @[@"transform",@"backgroundColor"];
-    for (NSString *propertyName in animationModuleArray) {
-        if ([propertyNames containsString:propertyName]) {
-            [self _dealTransitionWithProperty:propertyName styles:styles];
-        }
+    NSString *singleProperty = styles.allKeys[0];
+    if ([propertyNames containsString:singleProperty]) {
+        [self _dealTransitionWithProperty:singleProperty styles:styles];
     }
 }
 
-- (void)_judgeProperty:(NSString *)singleProperty
-{
-    WXTransitionInfo *info = [WXTransitionInfo new];
-    info.fromValue = @(_fromStyles[singleProperty] ? [WXConvert 
CGFloat:_fromStyles[singleProperty]] : 0);
-    info.toValue = @(_toStyles[singleProperty] ? [WXConvert 
CGFloat:_toStyles[singleProperty]] : 0 );
-    info.perValue = @([info.toValue floatValue] - [info.fromValue floatValue]);
-    info.propertyName = singleProperty;
-    if (!_propertyArray) {
-        _propertyArray = [NSMutableArray new];
-    }
-    [_propertyArray addObject:info];
-}
-
 - (void)_dealTransitionWithProperty:(NSString *)singleProperty 
styles:(NSDictionary *)styles
 {
     if (styles[singleProperty])
@@ -186,7 +162,7 @@
             info.propertyName = singleProperty;
             [_propertyArray addObject:info];
         }
-        if ([singleProperty isEqualToString:@"transform"]) {
+        else if ([singleProperty isEqualToString:@"transform"]) {
             NSString *transformOrigin = styles[@"transformOrigin"];
             WXTransform *wxTransform = [[WXTransform alloc] 
initWithCSSValue:_toStyles[singleProperty] origin:transformOrigin 
instance:_targetComponent.weexInstance];
             WXTransform *oldTransform = _targetComponent->_transform;
@@ -195,7 +171,7 @@
                 info.propertyName = @"transform.rotation";
                 info.fromValue = @(oldTransform.rotateAngle);
                 info.toValue = [NSNumber 
numberWithDouble:wxTransform.rotateAngle];
-                info.perValue = @([info.toValue floatValue] - [info.fromValue 
floatValue]);
+                info.perValue = @([info.toValue doubleValue] - [info.fromValue 
doubleValue]);
                 [_propertyArray addObject:info];
             }
             if (wxTransform.rotateX != oldTransform.rotateX)
@@ -204,7 +180,7 @@
                 info.propertyName = @"transform.rotation.x";
                 info.fromValue = @(oldTransform.rotateX);
                 info.toValue = [NSNumber numberWithDouble:wxTransform.rotateX];
-                info.perValue = @([info.toValue floatValue] - [info.fromValue 
floatValue]);
+                info.perValue = @([info.toValue doubleValue] - [info.fromValue 
doubleValue]);
                 [_propertyArray addObject:info];
             }
             if (wxTransform.rotateY != oldTransform.rotateY)
@@ -213,7 +189,7 @@
                 info.propertyName = @"transform.rotation.y";
                 info.fromValue = @(oldTransform.rotateY);
                 info.toValue = [NSNumber numberWithDouble:wxTransform.rotateY];
-                info.perValue = @([info.toValue floatValue] - [info.fromValue 
floatValue]);
+                info.perValue = @([info.toValue doubleValue] - [info.fromValue 
doubleValue]);
                 [_propertyArray addObject:info];
             }
             if (wxTransform.rotateZ != oldTransform.rotateZ)
@@ -222,25 +198,23 @@
                 info.propertyName = @"transform.rotation.z";
                 info.fromValue = @(oldTransform.rotateZ);
                 info.toValue = [NSNumber numberWithDouble:wxTransform.rotateZ];
-                info.perValue = @([info.toValue floatValue] - [info.fromValue 
floatValue]);
+                info.perValue = @([info.toValue doubleValue] - [info.fromValue 
doubleValue]);
                 [_propertyArray addObject:info];
             }
-            
             if (wxTransform.scaleX != oldTransform.scaleX) {
                 WXTransitionInfo *info = [WXTransitionInfo new];
                 info.propertyName = @"transform.scale.x";
                 info.fromValue = @(oldTransform.scaleX);
                 info.toValue = @(wxTransform.scaleX);
-                info.perValue = @([info.toValue floatValue] - [info.fromValue 
floatValue]);
+                info.perValue = @([info.toValue doubleValue] - [info.fromValue 
doubleValue]);
                 [_propertyArray addObject:info];
             }
-            
             if (wxTransform.scaleY != oldTransform.scaleY) {
                 WXTransitionInfo *info = [WXTransitionInfo new];
                 info.propertyName = @"transform.scale.y";
                 info.fromValue = @(oldTransform.scaleY);
-                info.toValue = @(wxTransform.scaleX);
-                info.perValue = @([info.toValue floatValue] - [info.fromValue 
floatValue]);
+                info.toValue = @(wxTransform.scaleY);
+                info.perValue = @([info.toValue doubleValue] - [info.fromValue 
doubleValue]);
                 [_propertyArray addObject:info];
             }
             if (wxTransform.translateX && [wxTransform.translateX floatValue] 
!=[oldTransform.translateX floatValue]) {
@@ -261,6 +235,15 @@
             }
             _targetComponent->_transform = wxTransform;
         }
+        else
+        {
+            WXTransitionInfo *info = [WXTransitionInfo new];
+            info.fromValue = @(_fromStyles[singleProperty] ? [WXConvert 
CGFloat:_fromStyles[singleProperty]] : 0);
+            info.toValue = @(_toStyles[singleProperty] ? [WXConvert 
CGFloat:_toStyles[singleProperty]] : 0 );
+            info.perValue = @([info.toValue doubleValue] - [info.fromValue 
doubleValue]);
+            info.propertyName = singleProperty;
+            [_propertyArray addObject:info];
+        }
     }
 }
 
@@ -280,14 +263,14 @@
     return @[@(R),@(G),@(B),@(A)];
 }
 
-- (void)_calculateLayoutAnimationProcessingStyle
+- (void)_calculatetransitionProcessingStyle
 {
     if (_propertyArray.count == 0) {
         return;
     }
-    double per = 1000 * (_layoutAnimationCount + 1 ) / (60 * 
_layoutAnimationDuration);//linear
-    if (![[NSString stringWithFormat:@"%@",_layoutAnimationTimingFunction] 
isEqualToString: kCAMediaTimingFunctionLinear]) {
-        per = [self 
solveWithx:((_layoutAnimationCount+2)*16)/_layoutAnimationDuration 
epsilon:SOLVE_EPS(_layoutAnimationDuration)];
+    double per = 1000 * (_transitionCount + 1 ) / (60 * 
_transitionDuration);//linear
+    if (![[NSString stringWithFormat:@"%@",_transitionTimingFunction] 
isEqualToString: kCAMediaTimingFunctionLinear]) {
+        per = [self solveWithx:((_transitionCount+2)*16)/_transitionDuration 
epsilon:SOLVE_EPS(_transitionDuration)];
     }
     NSString *transformString = [NSString string];
     for (WXTransitionInfo *info in _propertyArray) {
@@ -357,73 +340,73 @@
 }
 
 #pragma mark CADisplayLink
-- (void)_startLayoutAnimationDisplayLink
+- (void)_startTransitionDisplayLink
 {
     WXAssertComponentThread();
-    if (!_layoutAnimationDisplayLink) {
-        _layoutAnimationDisplayLink = [CADisplayLink 
displayLinkWithTarget:self 
selector:@selector(_handleLayoutAnimationDisplayLink)];
-        [_layoutAnimationDisplayLink addToRunLoop:[NSRunLoop currentRunLoop] 
forMode:NSDefaultRunLoopMode];
+    if (!_transitionDisplayLink) {
+        _transitionDisplayLink = [CADisplayLink displayLinkWithTarget:self 
selector:@selector(_handleTransitionDisplayLink)];
+        [_transitionDisplayLink addToRunLoop:[NSRunLoop currentRunLoop] 
forMode:NSDefaultRunLoopMode];
     }
     else{
-        [self _awakeLayoutAnimationDisplayLink];
+        [self _awakeTransitionDisplayLink];
     }
 }
 
-- (void)_stopLayoutAnimationDisplayLink
+- (void)_stopTransitionDisplayLink
 {
     WXAssertComponentThread();
-    if (_layoutAnimationDisplayLink) {
-        [_layoutAnimationDisplayLink invalidate];
-        _layoutAnimationDisplayLink = nil;
+    if (_transitionDisplayLink) {
+        [_transitionDisplayLink invalidate];
+        _transitionDisplayLink = nil;
     }
 }
 
-- (BOOL)_isLayoutAnimationRunning
+- (BOOL)_isTransitionRunning
 {
     WXAssertComponentThread();
     BOOL yesOrNo = NO;
-    if (!_layoutAnimationDisplayLink.paused && _layoutAnimationCount >= 5) {
+    if (!_transitionDisplayLink.paused && _transitionCount >= 5) {
         yesOrNo = YES;
     }
     return yesOrNo;
 }
 
-- (void)_suspendLayoutAnimationDisplayLink
+- (void)_suspendTransitionDisplayLink
 {
     WXAssertComponentThread();
-    if(_layoutAnimationDisplayLink && !_layoutAnimationDisplayLink.paused){
-        _layoutAnimationDisplayLink.paused = YES;
+    if(_transitionDisplayLink && !_transitionDisplayLink.paused){
+        _transitionDisplayLink.paused = YES;
     }
 }
 
-- (void)_awakeLayoutAnimationDisplayLink
+- (void)_awakeTransitionDisplayLink
 {
     WXAssertComponentThread();
-    if (_layoutAnimationDisplayLink && _layoutAnimationDisplayLink.paused) {
-        _layoutAnimationDisplayLink.paused = NO;
+    if (_transitionDisplayLink && _transitionDisplayLink.paused) {
+        _transitionDisplayLink.paused = NO;
     }
 }
 
-- (void)_handleLayoutAnimationDisplayLink
+- (void)_handleTransitionDisplayLink
 {
     WXAssertComponentThread();
-    int count = _layoutAnimationDuration * 60 / 1000;
-    if (_layoutAnimationCount >= count) {
-        [self _suspendLayoutAnimationDisplayLink];
+    int count = _transitionDuration * 60 / 1000;
+    if (_transitionCount >= count) {
+        [self _suspendTransitionDisplayLink];
         [self _resetProcessAnimationParameter];
         return;
     }
     else
     {
-        [self _calculateLayoutAnimationProcessingStyle];
+        [self _calculatetransitionProcessingStyle];
     }
-    _layoutAnimationCount ++;
+    _transitionCount ++;
 }
 
 - (void)_resetProcessAnimationParameter
 {
-    _layoutAnimationCount = 0;
-    _layoutAnimationDuration = 0;
+    _transitionCount = 0;
+    _transitionDuration = 0;
     _propertyArray = nil;
 
     _addStyles = nil;

Reply via email to