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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to