You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by doumafang <gi...@git.apache.org> on 2017/08/08 12:36:27 UTC

[GitHub] incubator-weex pull request #581: + [ios] LayoutAnimation

GitHub user doumafang opened a pull request:

    https://github.com/apache/incubator-weex/pull/581

    + [ios] LayoutAnimation

    Layout Animation Base on CADisplayLink,to create generated frame animation.


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/doumafang/incubator-weex ios-feature-layoutanimation-0.16dev

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/incubator-weex/pull/581.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #581
    
----
commit 6bd86e5625bff1310a48244fd2c74db307b9314e
Author: doumafang <do...@gmail.com>
Date:   2017-08-08T12:31:03Z

    + [ios] LayoutAnimation

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-weex pull request #581: + [ios] LayoutAnimation

Posted by cxfeng1 <gi...@git.apache.org>.
Github user cxfeng1 commented on a diff in the pull request:

    https://github.com/apache/incubator-weex/pull/581#discussion_r132132579
  
    --- Diff: ios/sdk/WeexSDK/Sources/Layout/WXComponent+Layout.m ---
    @@ -409,4 +617,77 @@ static css_dim_t cssNodeMeasure(void *context, float width, css_measure_mode_t w
         return (css_dim_t){resultSize.width, resultSize.height};
     }
     
    +//贝塞尔曲线计算
    --- End diff --
    
    Use English comments


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-weex issue #581: + [ios] LayoutAnimation

Posted by weex-bot <gi...@git.apache.org>.
Github user weex-bot commented on the issue:

    https://github.com/apache/incubator-weex/pull/581
  
    
    <!--
      1 failure:  This PR modify SD...
      2 warning:  No Changelog chan..., This PR should up...
      1 messages
      
    -->
    
    <table>
      <thead>
        <tr>
          <th width="50"></th>
          <th width="100%" data-danger-table="true">Fails</th>
        </tr>
      </thead>
      <tbody><tr>
          <td>:no_entry_sign:</td>
          <td>This PR modify SDK code. Please add/modify corresponding testcases. If it is ok, please comment about it. Or put '@notdanger' in you commit message.</td>
        </tr>
      </tbody>
    </table>
    
    
    <table>
      <thead>
        <tr>
          <th width="50"></th>
          <th width="100%" data-danger-table="true">Warnings</th>
        </tr>
      </thead>
      <tbody><tr>
          <td>:warning:</td>
          <td>No Changelog changes!</td>
        </tr>
      
    <tr>
          <td>:warning:</td>
          <td>This PR should update related documents as well. </td>
        </tr>
      </tbody>
    </table>
    
    
    <table>
      <thead>
        <tr>
          <th width="50"></th>
          <th width="100%" data-danger-table="true">Messages</th>
        </tr>
      </thead>
      <tbody><tr>
          <td>:book:</td>
          <td>According to the blame info, we recommended @bluebird78999 , @cxfeng1 to be the reviewers.</td>
        </tr>
      </tbody>
    </table>
    
    
    <p align="right">
      Generated by :no_entry_sign: <a href="http://github.com/danger/danger-js/">dangerJS</a>
    </p>



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-weex pull request #581: + [ios] LayoutAnimation

Posted by cxfeng1 <gi...@git.apache.org>.
Github user cxfeng1 commented on a diff in the pull request:

    https://github.com/apache/incubator-weex/pull/581#discussion_r132132975
  
    --- Diff: ios/sdk/WeexSDK/Sources/Module/WXAnimationLayout.h ---
    @@ -1,49 +1,49 @@
    -/*
    - * Licensed to the Apache Software Foundation (ASF) under one
    - * or more contributor license agreements.  See the NOTICE file
    - * distributed with this work for additional information
    - * regarding copyright ownership.  The ASF licenses this file
    - * to you under the Apache License, Version 2.0 (the
    - * "License"); you may not use this file except in compliance
    - * with the License.  You may obtain a copy of the License at
    - *
    - *   http://www.apache.org/licenses/LICENSE-2.0
    - *
    - * Unless required by applicable law or agreed to in writing,
    - * software distributed under the License is distributed on an
    - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    - * KIND, either express or implied.  See the License for the
    - * specific language governing permissions and limitations
    - * under the License.
    - */
    -
    -#import <Foundation/Foundation.h>
    -
    -#import "WXComponent.h"
    -#import "WXComponent_internal.h"
    -#import "NSTimer+Weex.h"
    -
    -@interface WXAnimationLayoutInfo : NSObject
    -
    -@property (nonatomic, strong) NSString *propertyName;
    -@property (nonatomic, strong) id fromValue;
    -@property (nonatomic, strong) id toValue;
    -
    -@end
    -
    -
    -@interface WXAnimationLayout : NSObject
    -
    -@property (nonatomic,strong) NSTimer *updateStyleTimer;
    -@property (nonatomic,strong) WXComponent *targetComponent;
    -@property (nonatomic,strong) NSDate *animationStartDate;
    -@property (nonatomic,strong) WXAnimationLayoutInfo *widthInfo;
    -@property (nonatomic,strong) WXAnimationLayoutInfo *heightInfo;
    -@property (nonatomic,assign) double animationDuration;
    -@property (nonatomic,assign) double animationDelay;
    -@property (nonatomic,strong) NSDictionary *needUpdateStyles;
    -@property (nonatomic, weak) WXSDKInstance *weexInstance;
    -
    -- (void)layoutForAnimation;
    -
    -@end
    +///*
    --- End diff --
    
    Just delete WXAnimationLayout.h/m


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-weex pull request #581: + [ios] LayoutAnimation

Posted by cxfeng1 <gi...@git.apache.org>.
Github user cxfeng1 commented on a diff in the pull request:

    https://github.com/apache/incubator-weex/pull/581#discussion_r132130861
  
    --- Diff: ios/sdk/WeexSDK/Sources/Layout/WXComponent+Layout.m ---
    @@ -112,6 +115,211 @@ - (NSUInteger)_childrenCountForLayout
         return (int)(count);
     }
     
    +
    +#pragma mark LayoutAnimationDisplayLink
    +- (void)_startLayoutAnimationDisplayLink
    +{
    +    WXAssertComponentThread();
    +    if (!_layoutAnimationDisplayLink) {
    +        _layoutAnimationDisplayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(_handleLayoutAnimationDisplayLink)];
    +        [_layoutAnimationDisplayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
    +    }
    +    else{
    +        [self _awakeLayoutAnimationDisplayLink];
    +    }
    +    
    +}
    +
    +- (void)_stopLayoutAnimationDisplayLink
    +{
    +    WXAssertComponentThread();
    +    if (_layoutAnimationDisplayLink) {
    +        [_layoutAnimationDisplayLink invalidate];
    +        _layoutAnimationDisplayLink = nil;
    +    }
    +}
    +
    +- (void)_suspendLayoutAnimationDisplayLink
    +{
    +    WXAssertComponentThread();
    +    if(_layoutAnimationDisplayLink && !_layoutAnimationDisplayLink.paused)
    +    {
    +        _layoutAnimationDisplayLink.paused = YES;
    +    }
    +}
    +
    +
    +- (void)_awakeLayoutAnimationDisplayLink
    +{
    +    WXAssertComponentThread();
    +    if (_layoutAnimationDisplayLink && _layoutAnimationDisplayLink.paused) {
    +        _layoutAnimationDisplayLink.paused = NO;
    +    }
    +}
    +
    +- (void)_handleLayoutAnimationDisplayLink
    +{
    +    WXAssertComponentThread();
    +    int count = _layoutAnimationDuration * 60 / 1000;
    +    if (_layoutAnimationCount >= count) {
    +        [self _suspendLayoutAnimationDisplayLink];
    +        [self _resetProcessAnimationParameter];
    +        return;
    +    }
    +    else
    +    {
    +        [self _calculateLayoutAnimationProcessingStyle];
    +    }
    +    _layoutAnimationCount ++;
    +}
    +
    +
    +- (void)_resetProcessAnimationParameter
    +{
    +    
    +    _layoutAnimationCount = 0;
    +    _layoutAnimationDuration = 0;
    +    _widthInfo = nil;
    +    _heightInfo = nil;
    +    _leftInfo = nil;
    +    _rightInfo = nil;
    +    _topInfo = nil;
    +    _bottomInfo = nil;
    +}
    +
    +- (void)_handleLayoutAnimationWithStyles:(NSDictionary *)styles
    +{
    +    [self _suspendLayoutAnimationDisplayLink];
    +    
    +    if (!_addStyles) {
    +        _fromStyles = [NSMutableDictionary dictionaryWithDictionary:self.styles];
    +        _addStyles = [NSMutableDictionary dictionaryWithDictionary:styles];
    +    }
    +    else
    +    {
    +        [_addStyles addEntriesFromDictionary:styles];
    +    }//保证_addStyles是唯一的
    +    
    +    _toStyles = [NSMutableDictionary dictionaryWithDictionary:_fromStyles];
    +    [_toStyles addEntriesFromDictionary:_addStyles];
    +    
    +    _layoutAnimationDuration = _fromStyles[@"transitionDuration"] ? [WXConvert CGFloat:_fromStyles[@"transitionDuration"]] : 0;
    +    _layoutAnimationDelay = _fromStyles[@"transitionDelay"] ? [WXConvert CGFloat:_fromStyles[@"transitionDelay"]] : 0;
    +    _layoutAnimationTimingFunction = [WXConvert CAMediaTimingFunction:_fromStyles[@"transitionTimingFunction"]];
    +    
    +    
    +    if (_layoutAnimationDuration == 0) {
    +        [self _fillCSSNode:styles];
    +        return;//如果duration为零直接关闭动画效果
    --- End diff --
    
    Use English Comments.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-weex pull request #581: + [ios] LayoutAnimation

Posted by cxfeng1 <gi...@git.apache.org>.
Github user cxfeng1 commented on a diff in the pull request:

    https://github.com/apache/incubator-weex/pull/581#discussion_r132132531
  
    --- Diff: ios/sdk/WeexSDK/Sources/Layout/WXComponent+Layout.m ---
    @@ -112,6 +115,211 @@ - (NSUInteger)_childrenCountForLayout
         return (int)(count);
     }
     
    +
    +#pragma mark LayoutAnimationDisplayLink
    +- (void)_startLayoutAnimationDisplayLink
    +{
    +    WXAssertComponentThread();
    +    if (!_layoutAnimationDisplayLink) {
    +        _layoutAnimationDisplayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(_handleLayoutAnimationDisplayLink)];
    +        [_layoutAnimationDisplayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
    +    }
    +    else{
    +        [self _awakeLayoutAnimationDisplayLink];
    +    }
    +    
    +}
    +
    +- (void)_stopLayoutAnimationDisplayLink
    +{
    +    WXAssertComponentThread();
    +    if (_layoutAnimationDisplayLink) {
    +        [_layoutAnimationDisplayLink invalidate];
    +        _layoutAnimationDisplayLink = nil;
    +    }
    +}
    +
    +- (void)_suspendLayoutAnimationDisplayLink
    +{
    +    WXAssertComponentThread();
    +    if(_layoutAnimationDisplayLink && !_layoutAnimationDisplayLink.paused)
    +    {
    +        _layoutAnimationDisplayLink.paused = YES;
    +    }
    +}
    +
    +
    +- (void)_awakeLayoutAnimationDisplayLink
    +{
    +    WXAssertComponentThread();
    +    if (_layoutAnimationDisplayLink && _layoutAnimationDisplayLink.paused) {
    +        _layoutAnimationDisplayLink.paused = NO;
    +    }
    +}
    +
    +- (void)_handleLayoutAnimationDisplayLink
    +{
    +    WXAssertComponentThread();
    +    int count = _layoutAnimationDuration * 60 / 1000;
    +    if (_layoutAnimationCount >= count) {
    +        [self _suspendLayoutAnimationDisplayLink];
    +        [self _resetProcessAnimationParameter];
    +        return;
    +    }
    +    else
    +    {
    +        [self _calculateLayoutAnimationProcessingStyle];
    +    }
    +    _layoutAnimationCount ++;
    +}
    +
    +
    +- (void)_resetProcessAnimationParameter
    +{
    +    
    +    _layoutAnimationCount = 0;
    +    _layoutAnimationDuration = 0;
    +    _widthInfo = nil;
    +    _heightInfo = nil;
    +    _leftInfo = nil;
    +    _rightInfo = nil;
    +    _topInfo = nil;
    +    _bottomInfo = nil;
    +}
    +
    +- (void)_handleLayoutAnimationWithStyles:(NSDictionary *)styles
    +{
    +    [self _suspendLayoutAnimationDisplayLink];
    +    
    +    if (!_addStyles) {
    +        _fromStyles = [NSMutableDictionary dictionaryWithDictionary:self.styles];
    +        _addStyles = [NSMutableDictionary dictionaryWithDictionary:styles];
    +    }
    +    else
    +    {
    +        [_addStyles addEntriesFromDictionary:styles];
    +    }//保证_addStyles是唯一的
    +    
    +    _toStyles = [NSMutableDictionary dictionaryWithDictionary:_fromStyles];
    +    [_toStyles addEntriesFromDictionary:_addStyles];
    +    
    +    _layoutAnimationDuration = _fromStyles[@"transitionDuration"] ? [WXConvert CGFloat:_fromStyles[@"transitionDuration"]] : 0;
    +    _layoutAnimationDelay = _fromStyles[@"transitionDelay"] ? [WXConvert CGFloat:_fromStyles[@"transitionDelay"]] : 0;
    +    _layoutAnimationTimingFunction = [WXConvert CAMediaTimingFunction:_fromStyles[@"transitionTimingFunction"]];
    +    
    +    
    +    if (_layoutAnimationDuration == 0) {
    +        [self _fillCSSNode:styles];
    +        return;//如果duration为零直接关闭动画效果
    +    }
    +    
    +    if (![[NSString stringWithFormat:@"%@",_layoutAnimationTimingFunction] isEqualToString: kCAMediaTimingFunctionLinear]) {
    +        float vec[4] = {0.};
    +        [_layoutAnimationTimingFunction getControlPointAtIndex:1 values:&vec[0]];
    +        [_layoutAnimationTimingFunction getControlPointAtIndex:2 values:&vec[2]];
    +        [self unitBezierp1x:vec[0] p1y:vec[1] p2x:vec[2] p2y:vec[3]];
    +    }
    +    
    +    
    +    NSString *layoutAnimationProperty = _fromStyles[@"transitionProperty"];
    +    if ([layoutAnimationProperty containsString:@"width"]) {
    +        _widthInfo = [WXLayoutAnimationInfo new];
    +        _widthInfo.isAnimated = YES;
    +        _widthInfo.fromValue = @(_fromStyles[@"width"] ? [WXConvert CGFloat:_fromStyles[@"width" ]] : 0);
    +        _widthInfo.toValue = @(_toStyles[@"width"] ? [WXConvert CGFloat:_toStyles[@"width"]] : 0 );
    +        _widthInfo.perValue = @([_widthInfo.toValue doubleValue] - [_widthInfo.fromValue doubleValue]);
    +        
    +    }
    +    if ([layoutAnimationProperty containsString:@"height"])
    +    {
    +        _heightInfo = [WXLayoutAnimationInfo new];
    +        _heightInfo.isAnimated = YES;
    +        _heightInfo.fromValue = @(_fromStyles[@"height"] ? [WXConvert CGFloat:_fromStyles[@"height" ]] : 0);
    +        _heightInfo.toValue = @(_toStyles[@"height"] ? [WXConvert CGFloat:_toStyles[@"height"]] : 0 );
    +        _heightInfo.perValue = @([_heightInfo.toValue doubleValue] - [_heightInfo.fromValue doubleValue]);
    +        
    +    }
    +    if ([layoutAnimationProperty containsString:@"left"])
    +    {
    +        _leftInfo = [WXLayoutAnimationInfo new];
    +        _leftInfo.isAnimated = YES;
    +        _leftInfo.fromValue = @(_fromStyles[@"left"] ? [WXConvert CGFloat:_fromStyles[@"left" ]] : 0);
    +        _leftInfo.toValue = @(_toStyles[@"left"] ? [WXConvert CGFloat:_toStyles[@"left"]] : 0 );
    +        _leftInfo.perValue = @([_leftInfo.toValue doubleValue] - [_leftInfo.fromValue doubleValue]);
    +        
    +    }
    +    if ([layoutAnimationProperty containsString:@"right"])
    +    {
    +        _rightInfo = [WXLayoutAnimationInfo new];
    +        _rightInfo.isAnimated = YES;
    +        _rightInfo.fromValue = @(_fromStyles[@"right"] ? [WXConvert CGFloat:_fromStyles[@"right" ]] : 0);
    +        _rightInfo.toValue = @(_toStyles[@"right"] ? [WXConvert CGFloat:_toStyles[@"right"]] : 0 );
    +        _rightInfo.perValue = @([_rightInfo.toValue doubleValue] - [_rightInfo.fromValue doubleValue]);
    +        
    +    }
    +    if ([layoutAnimationProperty containsString:@"top"])
    +    {
    +        _topInfo = [WXLayoutAnimationInfo new];
    +        _topInfo.isAnimated = YES;
    +        _topInfo.fromValue = @(_fromStyles[@"top"] ? [WXConvert CGFloat:_fromStyles[@"top" ]] : 0);
    +        _topInfo.toValue = @(_toStyles[@"top"] ? [WXConvert CGFloat:_toStyles[@"top"]] : 0 );
    +        _topInfo.perValue = @([_topInfo.toValue doubleValue] - [_topInfo.fromValue doubleValue]);
    +        
    +    }
    +    if ([layoutAnimationProperty containsString:@"bottom"])
    +    {
    +        _bottomInfo = [WXLayoutAnimationInfo new];
    +        _bottomInfo.isAnimated = YES;
    +        _bottomInfo.fromValue = @(_fromStyles[@"bottom"] ? [WXConvert CGFloat:_fromStyles[@"bottom" ]] : 0);
    +        _bottomInfo.toValue = @(_toStyles[@"bottom"] ? [WXConvert CGFloat:_toStyles[@"bottom"]] : 0 );
    +        _bottomInfo.perValue = @([_widthInfo.toValue doubleValue] - [_bottomInfo.fromValue doubleValue]);
    +        
    +    }
    +    if ([layoutAnimationProperty containsString:@"transform"]) {
    +        
    +        
    +    }
    +    
    +    
    +    [self performSelector:@selector(_startLayoutAnimationDisplayLink) withObject:self afterDelay:_layoutAnimationDelay/1000];
    +    //    [self _startLayoutAnimationDisplayLink];
    +    
    +}
    +
    +
    +- (void)_calculateLayoutAnimationProcessingStyle
    +{
    +    //linear 在做贝塞尔曲线模型
    +    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 currentWidth = [_widthInfo.fromValue doubleValue] + [_widthInfo.perValue doubleValue] * per;
    +    double currentHeight = [_heightInfo.fromValue doubleValue] + [_heightInfo.perValue doubleValue] * per;
    +    double currentLeft = [_leftInfo.fromValue doubleValue] + [_leftInfo.perValue doubleValue] * per;
    +    double currentRight = [_rightInfo.fromValue doubleValue] + [_rightInfo.perValue doubleValue] * per;
    +    double currentTop = [_topInfo.fromValue doubleValue] + [_topInfo.perValue doubleValue] * per;
    +    double currentBottom = [_bottomInfo.fromValue doubleValue] + [_bottomInfo.perValue doubleValue] * per;
    +    
    +    
    +    
    +    _widthInfo.isAnimated ? [_fromStyles setObject:@(currentWidth) forKey:@"width"]:0;
    +    _heightInfo.isAnimated ? [_fromStyles setObject:@(currentHeight) forKey:@"height"]:0;
    +    _leftInfo.isAnimated ? [_fromStyles setObject:@(currentLeft) forKey:@"left"]:0;
    +    _rightInfo.isAnimated ? [_fromStyles setObject:@(currentRight) forKey:@"right"]:0;
    +    _topInfo.isAnimated ? [_fromStyles setObject:@(currentTop) forKey:@"top"]:0;
    +    _bottomInfo.isAnimated ? [_fromStyles setObject:@(currentBottom) forKey:@"bottom"]:0;
    +    
    +    NSLog(@"%@",_fromStyles);
    --- End diff --
    
    Don't use NSLog


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-weex pull request #581: + [ios] LayoutAnimation

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/incubator-weex/pull/581


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-weex issue #581: + [ios] LayoutAnimation

Posted by kernelj <gi...@git.apache.org>.
Github user kernelj commented on the issue:

    https://github.com/apache/incubator-weex/pull/581
  
    这是增加ios页面跳转的加载动画的吗


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-weex pull request #581: + [ios] LayoutAnimation

Posted by cxfeng1 <gi...@git.apache.org>.
Github user cxfeng1 commented on a diff in the pull request:

    https://github.com/apache/incubator-weex/pull/581#discussion_r132131367
  
    --- Diff: ios/sdk/WeexSDK/Sources/Model/WXComponent.m ---
    @@ -436,16 +436,35 @@ - (void)_moveToSupercomponent:(WXComponent *)newSupercomponent atIndex:(NSUInteg
     
     - (void)_updateStylesOnComponentThread:(NSDictionary *)styles resetStyles:(NSMutableArray *)resetStyles isUpdateStyles:(BOOL)isUpdateStyles
     {
    -    if (isUpdateStyles) {
    -        pthread_mutex_lock(&_propertyMutex);
    -        [_styles addEntriesFromDictionary:styles];
    -        pthread_mutex_unlock(&_propertyMutex);
    +    
    +    //根据当前的style是否含有transitionProperty属性来判断是否有Layout Animation
    --- End diff --
    
    Use English Comments


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-weex pull request #581: + [ios] LayoutAnimation

Posted by cxfeng1 <gi...@git.apache.org>.
Github user cxfeng1 commented on a diff in the pull request:

    https://github.com/apache/incubator-weex/pull/581#discussion_r132131448
  
    --- Diff: ios/sdk/WeexSDK/Sources/Model/WXComponent.m ---
    @@ -436,16 +436,35 @@ - (void)_moveToSupercomponent:(WXComponent *)newSupercomponent atIndex:(NSUInteg
     
     - (void)_updateStylesOnComponentThread:(NSDictionary *)styles resetStyles:(NSMutableArray *)resetStyles isUpdateStyles:(BOOL)isUpdateStyles
     {
    -    if (isUpdateStyles) {
    -        pthread_mutex_lock(&_propertyMutex);
    -        [_styles addEntriesFromDictionary:styles];
    -        pthread_mutex_unlock(&_propertyMutex);
    +    
    +    //根据当前的style是否含有transitionProperty属性来判断是否有Layout Animation
    +    if (_styles[@"transitionProperty"]) {
    --- End diff --
    
    Only transitionProperty?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-weex pull request #581: + [ios] LayoutAnimation

Posted by cxfeng1 <gi...@git.apache.org>.
Github user cxfeng1 commented on a diff in the pull request:

    https://github.com/apache/incubator-weex/pull/581#discussion_r132132151
  
    --- Diff: ios/sdk/WeexSDK/Sources/Layout/WXComponent+Layout.m ---
    @@ -112,6 +115,211 @@ - (NSUInteger)_childrenCountForLayout
         return (int)(count);
     }
     
    +
    +#pragma mark LayoutAnimationDisplayLink
    +- (void)_startLayoutAnimationDisplayLink
    +{
    +    WXAssertComponentThread();
    +    if (!_layoutAnimationDisplayLink) {
    +        _layoutAnimationDisplayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(_handleLayoutAnimationDisplayLink)];
    +        [_layoutAnimationDisplayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
    +    }
    +    else{
    +        [self _awakeLayoutAnimationDisplayLink];
    +    }
    +    
    +}
    +
    +- (void)_stopLayoutAnimationDisplayLink
    +{
    +    WXAssertComponentThread();
    +    if (_layoutAnimationDisplayLink) {
    +        [_layoutAnimationDisplayLink invalidate];
    +        _layoutAnimationDisplayLink = nil;
    +    }
    +}
    +
    +- (void)_suspendLayoutAnimationDisplayLink
    +{
    +    WXAssertComponentThread();
    +    if(_layoutAnimationDisplayLink && !_layoutAnimationDisplayLink.paused)
    +    {
    +        _layoutAnimationDisplayLink.paused = YES;
    +    }
    +}
    +
    +
    +- (void)_awakeLayoutAnimationDisplayLink
    +{
    +    WXAssertComponentThread();
    +    if (_layoutAnimationDisplayLink && _layoutAnimationDisplayLink.paused) {
    +        _layoutAnimationDisplayLink.paused = NO;
    +    }
    +}
    +
    +- (void)_handleLayoutAnimationDisplayLink
    +{
    +    WXAssertComponentThread();
    +    int count = _layoutAnimationDuration * 60 / 1000;
    +    if (_layoutAnimationCount >= count) {
    +        [self _suspendLayoutAnimationDisplayLink];
    +        [self _resetProcessAnimationParameter];
    +        return;
    +    }
    +    else
    +    {
    +        [self _calculateLayoutAnimationProcessingStyle];
    +    }
    +    _layoutAnimationCount ++;
    +}
    +
    +
    +- (void)_resetProcessAnimationParameter
    +{
    +    
    +    _layoutAnimationCount = 0;
    +    _layoutAnimationDuration = 0;
    +    _widthInfo = nil;
    +    _heightInfo = nil;
    +    _leftInfo = nil;
    +    _rightInfo = nil;
    +    _topInfo = nil;
    +    _bottomInfo = nil;
    +}
    +
    +- (void)_handleLayoutAnimationWithStyles:(NSDictionary *)styles
    +{
    +    [self _suspendLayoutAnimationDisplayLink];
    +    
    +    if (!_addStyles) {
    +        _fromStyles = [NSMutableDictionary dictionaryWithDictionary:self.styles];
    +        _addStyles = [NSMutableDictionary dictionaryWithDictionary:styles];
    +    }
    +    else
    +    {
    +        [_addStyles addEntriesFromDictionary:styles];
    +    }//保证_addStyles是唯一的
    +    
    +    _toStyles = [NSMutableDictionary dictionaryWithDictionary:_fromStyles];
    +    [_toStyles addEntriesFromDictionary:_addStyles];
    +    
    +    _layoutAnimationDuration = _fromStyles[@"transitionDuration"] ? [WXConvert CGFloat:_fromStyles[@"transitionDuration"]] : 0;
    +    _layoutAnimationDelay = _fromStyles[@"transitionDelay"] ? [WXConvert CGFloat:_fromStyles[@"transitionDelay"]] : 0;
    +    _layoutAnimationTimingFunction = [WXConvert CAMediaTimingFunction:_fromStyles[@"transitionTimingFunction"]];
    +    
    +    
    +    if (_layoutAnimationDuration == 0) {
    +        [self _fillCSSNode:styles];
    +        return;//如果duration为零直接关闭动画效果
    +    }
    +    
    +    if (![[NSString stringWithFormat:@"%@",_layoutAnimationTimingFunction] isEqualToString: kCAMediaTimingFunctionLinear]) {
    +        float vec[4] = {0.};
    +        [_layoutAnimationTimingFunction getControlPointAtIndex:1 values:&vec[0]];
    +        [_layoutAnimationTimingFunction getControlPointAtIndex:2 values:&vec[2]];
    +        [self unitBezierp1x:vec[0] p1y:vec[1] p2x:vec[2] p2y:vec[3]];
    +    }
    +    
    +    
    +    NSString *layoutAnimationProperty = _fromStyles[@"transitionProperty"];
    +    if ([layoutAnimationProperty containsString:@"width"]) {
    +        _widthInfo = [WXLayoutAnimationInfo new];
    +        _widthInfo.isAnimated = YES;
    +        _widthInfo.fromValue = @(_fromStyles[@"width"] ? [WXConvert CGFloat:_fromStyles[@"width" ]] : 0);
    +        _widthInfo.toValue = @(_toStyles[@"width"] ? [WXConvert CGFloat:_toStyles[@"width"]] : 0 );
    +        _widthInfo.perValue = @([_widthInfo.toValue doubleValue] - [_widthInfo.fromValue doubleValue]);
    +        
    +    }
    +    if ([layoutAnimationProperty containsString:@"height"])
    +    {
    +        _heightInfo = [WXLayoutAnimationInfo new];
    +        _heightInfo.isAnimated = YES;
    +        _heightInfo.fromValue = @(_fromStyles[@"height"] ? [WXConvert CGFloat:_fromStyles[@"height" ]] : 0);
    +        _heightInfo.toValue = @(_toStyles[@"height"] ? [WXConvert CGFloat:_toStyles[@"height"]] : 0 );
    +        _heightInfo.perValue = @([_heightInfo.toValue doubleValue] - [_heightInfo.fromValue doubleValue]);
    +        
    +    }
    +    if ([layoutAnimationProperty containsString:@"left"])
    +    {
    +        _leftInfo = [WXLayoutAnimationInfo new];
    +        _leftInfo.isAnimated = YES;
    +        _leftInfo.fromValue = @(_fromStyles[@"left"] ? [WXConvert CGFloat:_fromStyles[@"left" ]] : 0);
    +        _leftInfo.toValue = @(_toStyles[@"left"] ? [WXConvert CGFloat:_toStyles[@"left"]] : 0 );
    +        _leftInfo.perValue = @([_leftInfo.toValue doubleValue] - [_leftInfo.fromValue doubleValue]);
    +        
    +    }
    +    if ([layoutAnimationProperty containsString:@"right"])
    +    {
    +        _rightInfo = [WXLayoutAnimationInfo new];
    +        _rightInfo.isAnimated = YES;
    +        _rightInfo.fromValue = @(_fromStyles[@"right"] ? [WXConvert CGFloat:_fromStyles[@"right" ]] : 0);
    +        _rightInfo.toValue = @(_toStyles[@"right"] ? [WXConvert CGFloat:_toStyles[@"right"]] : 0 );
    +        _rightInfo.perValue = @([_rightInfo.toValue doubleValue] - [_rightInfo.fromValue doubleValue]);
    +        
    +    }
    +    if ([layoutAnimationProperty containsString:@"top"])
    +    {
    +        _topInfo = [WXLayoutAnimationInfo new];
    +        _topInfo.isAnimated = YES;
    +        _topInfo.fromValue = @(_fromStyles[@"top"] ? [WXConvert CGFloat:_fromStyles[@"top" ]] : 0);
    +        _topInfo.toValue = @(_toStyles[@"top"] ? [WXConvert CGFloat:_toStyles[@"top"]] : 0 );
    +        _topInfo.perValue = @([_topInfo.toValue doubleValue] - [_topInfo.fromValue doubleValue]);
    +        
    +    }
    +    if ([layoutAnimationProperty containsString:@"bottom"])
    +    {
    +        _bottomInfo = [WXLayoutAnimationInfo new];
    +        _bottomInfo.isAnimated = YES;
    +        _bottomInfo.fromValue = @(_fromStyles[@"bottom"] ? [WXConvert CGFloat:_fromStyles[@"bottom" ]] : 0);
    +        _bottomInfo.toValue = @(_toStyles[@"bottom"] ? [WXConvert CGFloat:_toStyles[@"bottom"]] : 0 );
    +        _bottomInfo.perValue = @([_widthInfo.toValue doubleValue] - [_bottomInfo.fromValue doubleValue]);
    +        
    +    }
    +    if ([layoutAnimationProperty containsString:@"transform"]) {
    +        
    +        
    +    }
    +    
    +    
    +    [self performSelector:@selector(_startLayoutAnimationDisplayLink) withObject:self afterDelay:_layoutAnimationDelay/1000];
    +    //    [self _startLayoutAnimationDisplayLink];
    +    
    +}
    +
    +
    +- (void)_calculateLayoutAnimationProcessingStyle
    +{
    +    //linear 在做贝塞尔曲线模型
    --- End diff --
    
    Use English comments


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-weex pull request #581: + [ios] LayoutAnimation

Posted by cxfeng1 <gi...@git.apache.org>.
Github user cxfeng1 commented on a diff in the pull request:

    https://github.com/apache/incubator-weex/pull/581#discussion_r132130697
  
    --- Diff: ios/sdk/WeexSDK/Sources/Layout/WXComponent+Layout.m ---
    @@ -112,6 +115,211 @@ - (NSUInteger)_childrenCountForLayout
         return (int)(count);
     }
     
    +
    +#pragma mark LayoutAnimationDisplayLink
    +- (void)_startLayoutAnimationDisplayLink
    +{
    +    WXAssertComponentThread();
    +    if (!_layoutAnimationDisplayLink) {
    +        _layoutAnimationDisplayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(_handleLayoutAnimationDisplayLink)];
    +        [_layoutAnimationDisplayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
    +    }
    +    else{
    +        [self _awakeLayoutAnimationDisplayLink];
    +    }
    +    
    +}
    +
    +- (void)_stopLayoutAnimationDisplayLink
    +{
    +    WXAssertComponentThread();
    +    if (_layoutAnimationDisplayLink) {
    +        [_layoutAnimationDisplayLink invalidate];
    +        _layoutAnimationDisplayLink = nil;
    +    }
    +}
    +
    +- (void)_suspendLayoutAnimationDisplayLink
    +{
    +    WXAssertComponentThread();
    +    if(_layoutAnimationDisplayLink && !_layoutAnimationDisplayLink.paused)
    +    {
    +        _layoutAnimationDisplayLink.paused = YES;
    +    }
    +}
    +
    +
    +- (void)_awakeLayoutAnimationDisplayLink
    +{
    +    WXAssertComponentThread();
    +    if (_layoutAnimationDisplayLink && _layoutAnimationDisplayLink.paused) {
    +        _layoutAnimationDisplayLink.paused = NO;
    +    }
    +}
    +
    +- (void)_handleLayoutAnimationDisplayLink
    +{
    +    WXAssertComponentThread();
    +    int count = _layoutAnimationDuration * 60 / 1000;
    +    if (_layoutAnimationCount >= count) {
    +        [self _suspendLayoutAnimationDisplayLink];
    +        [self _resetProcessAnimationParameter];
    +        return;
    +    }
    +    else
    +    {
    +        [self _calculateLayoutAnimationProcessingStyle];
    +    }
    +    _layoutAnimationCount ++;
    +}
    +
    +
    +- (void)_resetProcessAnimationParameter
    +{
    +    
    +    _layoutAnimationCount = 0;
    +    _layoutAnimationDuration = 0;
    +    _widthInfo = nil;
    +    _heightInfo = nil;
    +    _leftInfo = nil;
    +    _rightInfo = nil;
    +    _topInfo = nil;
    +    _bottomInfo = nil;
    +}
    +
    +- (void)_handleLayoutAnimationWithStyles:(NSDictionary *)styles
    +{
    +    [self _suspendLayoutAnimationDisplayLink];
    +    
    +    if (!_addStyles) {
    +        _fromStyles = [NSMutableDictionary dictionaryWithDictionary:self.styles];
    +        _addStyles = [NSMutableDictionary dictionaryWithDictionary:styles];
    +    }
    +    else
    +    {
    +        [_addStyles addEntriesFromDictionary:styles];
    +    }//保证_addStyles是唯一的
    --- End diff --
    
    Use English Comments.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-weex pull request #581: + [ios] LayoutAnimation

Posted by kfeagle <gi...@git.apache.org>.
Github user kfeagle commented on a diff in the pull request:

    https://github.com/apache/incubator-weex/pull/581#discussion_r131900391
  
    --- Diff: ios/sdk/WeexSDK/Sources/Component/WXComponent_internal.h ---
    @@ -214,3 +251,11 @@
     - (void)setGradientLayer;
     
     @end
    +
    +@interface WXLayoutAnimationInfo : NSObject
    +@property (nonatomic, strong) id fromValue;
    --- End diff --
    
    use for CGfloat, maybe assign is better?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---