Skip to content

Commit

Permalink
fix(module: tree): fix animation of expand method (NG-ZORRO#2989)
Browse files Browse the repository at this point in the history
  • Loading branch information
simplejason authored and vthinkxie committed Feb 28, 2019
1 parent 353164e commit 2b52894
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 23 deletions.
8 changes: 3 additions & 5 deletions components/tree/nz-tree-node.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,10 @@

<ul
role="group"
class="ant-tree-child-tree"
[class.ant-tree-child-tree-open]="nzTreeNode.isExpanded"
[attr.data-expanded]="nzTreeNode.isExpanded"
[ngClass]="nzNodeChildrenClass"
class="ant-tree-child-tree ant-tree-child-tree-open"
data-expanded="true"
[@.disabled]="noAnimation?.nzNoAnimation"
[@nodeState]="nzTreeNode.isExpanded ? 'active' : 'inactive'">
[@collapseMotion]="nzTreeNode.isExpanded ? 'expanded' : 'collapsed'">
<nz-tree-node
*ngFor="let node of nzTreeNode.getChildren(); trackBy: trackByFn"
[nzTreeNode]="node"
Expand Down
19 changes: 2 additions & 17 deletions components/tree/nz-tree-node.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { animate, state, style, transition, trigger } from '@angular/animations';
import {
ChangeDetectionStrategy,
ChangeDetectorRef,
Expand All @@ -20,6 +19,7 @@ import {
} from '@angular/core';
import { fromEvent, Observable, Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators';
import { collapseMotion } from '../core/animation/collapse';
import { NzNoAnimationDirective } from '../core/no-animation/nz-no-animation.directive';
import { InputBoolean } from '../core/util/convert';
import { NzFormatBeforeDropEvent, NzFormatEmitEvent } from '../tree/interface';
Expand All @@ -32,21 +32,7 @@ import { isCheckDisabled } from './nz-tree-util';
templateUrl : './nz-tree-node.component.html',
changeDetection : ChangeDetectionStrategy.OnPush,
preserveWhitespaces: false,
animations : [
trigger('nodeState', [
state('inactive', style({
opacity: '0',
height : '0',
display: 'none'
})),
state('active', style({
opacity: '1',
height : '*'
})),
transition('inactive => active', animate('100ms ease-in')),
transition('active => inactive', animate('100ms ease-out'))
])
]
animations : [ collapseMotion ]
})

export class NzTreeNodeComponent implements OnInit, OnChanges, OnDestroy {
Expand Down Expand Up @@ -162,7 +148,6 @@ export class NzTreeNodeComponent implements OnInit, OnChanges, OnDestroy {
nzNodeCheckboxClass = {};
nzNodeContentIconClass = {};
nzNodeContentLoadingClass = {};
nzNodeChildrenClass = {};

/**
* drag var
Expand Down
4 changes: 3 additions & 1 deletion components/tree/nz-tree.module.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { NzAddOnModule } from '../core/addon/addon.module';
import { NzNoAnimationModule } from '../core/no-animation/nz-no-animation.module';
import { NzIconModule } from '../icon/nz-icon.module';
import { NzTreeNodeComponent } from './nz-tree-node.component';
Expand All @@ -9,7 +10,8 @@ import { NzTreeComponent } from './nz-tree.component';
imports: [
CommonModule,
NzIconModule,
NzNoAnimationModule
NzNoAnimationModule,
NzAddOnModule
],
declarations: [
NzTreeComponent,
Expand Down

0 comments on commit 2b52894

Please sign in to comment.