diff --git a/components/auto-complete/nz-autocomplete.component.html b/components/auto-complete/nz-autocomplete.component.html index 7f851317f4..5dfd9a258a 100644 --- a/components/auto-complete/nz-autocomplete.component.html +++ b/components/auto-complete/nz-autocomplete.component.html @@ -1,6 +1,7 @@
diff --git a/components/auto-complete/nz-autocomplete.component.ts b/components/auto-complete/nz-autocomplete.component.ts index dbd0f34ac3..a950b48fc6 100644 --- a/components/auto-complete/nz-autocomplete.component.ts +++ b/components/auto-complete/nz-autocomplete.component.ts @@ -6,16 +6,23 @@ import { ContentChildren, ElementRef, EventEmitter, - Input, NgZone, OnDestroy, + Host, + Input, + NgZone, + OnDestroy, + Optional, Output, QueryList, TemplateRef, - ViewChild, ViewChildren, ViewEncapsulation + ViewChild, + ViewChildren, + ViewEncapsulation } from '@angular/core'; import { defer, merge, Observable, Subscription } from 'rxjs'; import { filter, switchMap, take } from 'rxjs/operators'; import { slideMotion } from '../core/animation/slide'; +import { NzNoAnimationDirective } from '../core/no-animation/nz-no-animation.directive'; import { NzDropDownPosition } from '../core/types/drop-down-position'; import { InputBoolean } from '../core/util/convert'; import { NzAutocompleteOptionComponent, NzOptionSelectionChange } from './nz-autocomplete-option.component'; @@ -37,7 +44,7 @@ export type AutocompleteDataSource = AutocompleteDataSourceItem[] | string[] | n slideMotion ], styles : [ - ` + ` .ant-select-dropdown { top: 100%; left: 0; @@ -99,7 +106,8 @@ export class NzAutocompleteComponent implements AfterViewInit, OnDestroy { .pipe(take(1), switchMap(() => this.optionSelectionChanges)); }); - constructor(private changeDetectorRef: ChangeDetectorRef, private ngZone: NgZone) { + constructor(private changeDetectorRef: ChangeDetectorRef, private ngZone: NgZone, + @Host() @Optional() public noAnimation: NzNoAnimationDirective) { } ngAfterViewInit(): void { diff --git a/components/auto-complete/nz-autocomplete.module.ts b/components/auto-complete/nz-autocomplete.module.ts index bdcd4fbba7..a02ef65479 100644 --- a/components/auto-complete/nz-autocomplete.module.ts +++ b/components/auto-complete/nz-autocomplete.module.ts @@ -4,6 +4,7 @@ import { NgModule } from '@angular/core'; import { FormsModule } from '@angular/forms'; import { NzAddOnModule } from '../core/addon/addon.module'; +import { NzNoAnimationModule } from '../core/no-animation/nz-no-animation.module'; import { NzAutocompleteOptgroupComponent } from './nz-autocomplete-optgroup.component'; import { NzAutocompleteOptionComponent } from './nz-autocomplete-option.component'; @@ -13,7 +14,7 @@ import { NzAutocompleteComponent } from './nz-autocomplete.component'; @NgModule({ declarations: [NzAutocompleteComponent, NzAutocompleteOptionComponent, NzAutocompleteTriggerDirective, NzAutocompleteOptgroupComponent], exports: [NzAutocompleteComponent, NzAutocompleteOptionComponent, NzAutocompleteTriggerDirective, NzAutocompleteOptgroupComponent], - imports: [CommonModule, OverlayModule, FormsModule, NzAddOnModule] + imports: [CommonModule, OverlayModule, FormsModule, NzAddOnModule, NzNoAnimationModule] }) export class NzAutocompleteModule { } diff --git a/components/button/nz-button.component.ts b/components/button/nz-button.component.ts index 608ec24ba1..1c453c2cdb 100644 --- a/components/button/nz-button.component.ts +++ b/components/button/nz-button.component.ts @@ -19,6 +19,7 @@ import { ViewChild, ViewEncapsulation } from '@angular/core'; +import { ANIMATION_MODULE_TYPE } from '@angular/platform-browser/animations'; import { NzUpdateHostClassService } from '../core/services/update-host-class.service'; import { NzSizeLDSType } from '../core/types/size'; @@ -45,7 +46,7 @@ export class NzButtonComponent implements AfterContentInit, OnInit, OnDestroy, O private iconOnly = false; @ViewChild('contentElement') contentElement: ElementRef; @ContentChildren(NzIconDirective, { read: ElementRef }) listOfIconElement: QueryList; - @HostBinding('attr.nz-wave') nzWave = new NzWaveDirective(this.ngZone, this.elementRef, this.waveConfig); + @HostBinding('attr.nz-wave') nzWave = new NzWaveDirective(this.ngZone, this.elementRef, this.waveConfig, this.animationType); @Input() @InputBoolean() nzBlock = false; @Input() @InputBoolean() nzGhost = false; @Input() @InputBoolean() nzSearch = false; @@ -114,7 +115,8 @@ export class NzButtonComponent implements AfterContentInit, OnInit, OnDestroy, O private renderer: Renderer2, private nzUpdateHostClassService: NzUpdateHostClassService, private ngZone: NgZone, - @Optional() @Inject(NZ_WAVE_GLOBAL_CONFIG) private waveConfig: NzWaveConfig) { + @Optional() @Inject(NZ_WAVE_GLOBAL_CONFIG) private waveConfig: NzWaveConfig, + @Optional() @Inject(ANIMATION_MODULE_TYPE) private animationType: string) { } ngAfterContentInit(): void { diff --git a/components/cascader/nz-cascader.component.html b/components/cascader/nz-cascader.component.html index 2f1ae67f6c..dfee2bbde5 100644 --- a/components/cascader/nz-cascader.component.html +++ b/components/cascader/nz-cascader.component.html @@ -62,6 +62,7 @@ [class.ant-cascader-menus-hidden]="!menuVisible" [ngClass]="menuCls" [ngStyle]="nzMenuStyle" + [nzNoAnimation]="noAnimation?.nzNoAnimation" [@slideMotion]="dropDownPosition" (mouseleave)="onTriggerMouseLeave($event)">
    * { + transition: none; + } + } + + // modal + .ant-modal-mask, .ant-modal { + animation: none; + transition: none; + &.zoom-enter, &.zoom-leave, + &.zoom-enter-active, &.zoom-leave-active { + animation: none; + transition: none; + } + } + + // menu + &.ant-menu { + transition: none; + .ant-menu-item, .ant-menu-submenu-title { + transition: none; + } + .ant-menu-item .anticon, .ant-menu-submenu-title .anticon { + transition: none; + & + span { + transition: none; + } + } + } + + // tabs + &.ant-tabs { + .ant-tabs-top-content.ant-tabs-content-animated, + .ant-tabs-bottom-content.ant-tabs-content-animated, + .ant-tabs-top-content > .ant-tabs-tabpane, + .ant-tabs-bottom-content > .ant-tabs-tabpane, + &.ant-tabs-left .ant-tabs-ink-bar-animated, + &.ant-tabs-right .ant-tabs-ink-bar-animated, + &.ant-tabs-top .ant-tabs-ink-bar-animated, + &.ant-tabs-bottom .ant-tabs-ink-bar-animated { + transition: none; + } + } + + +} \ No newline at end of file diff --git a/components/core/wave/nz-wave.directive.ts b/components/core/wave/nz-wave.directive.ts index a329a484ea..71f5697f65 100644 --- a/components/core/wave/nz-wave.directive.ts +++ b/components/core/wave/nz-wave.directive.ts @@ -9,6 +9,7 @@ import { OnInit, Optional } from '@angular/core'; +import { ANIMATION_MODULE_TYPE } from '@angular/platform-browser/animations'; import { NzWaveRenderer } from './nz-wave-renderer'; export interface NzWaveConfig { @@ -39,10 +40,14 @@ export class NzWaveDirective implements OnInit, OnDestroy { constructor(private ngZone: NgZone, private elementRef: ElementRef, - @Optional() @Inject(NZ_WAVE_GLOBAL_CONFIG) config: NzWaveConfig) { + @Optional() @Inject(NZ_WAVE_GLOBAL_CONFIG) config: NzWaveConfig, + @Optional() @Inject(ANIMATION_MODULE_TYPE) private animationType: string) { if (config && typeof config.disabled === 'boolean') { this.waveDisabled = config.disabled; } + if (this.animationType === 'NoopAnimations') { + this.waveDisabled = true; + } } ngOnDestroy(): void { diff --git a/components/date-picker/abstract-picker.component.ts b/components/date-picker/abstract-picker.component.ts index 9bd4f2ed5e..5bd2ae3b87 100644 --- a/components/date-picker/abstract-picker.component.ts +++ b/components/date-picker/abstract-picker.component.ts @@ -13,6 +13,7 @@ import { ControlValueAccessor } from '@angular/forms'; import { Subject } from 'rxjs'; import { takeUntil } from 'rxjs/operators'; +import { NzNoAnimationDirective } from '../core/no-animation/nz-no-animation.directive'; import { InputBoolean } from '../core/util/convert'; import { DateHelperService } from '../i18n/date-helper.service'; import { NzDatePickerI18nInterface } from '../i18n/nz-i18n.interface'; @@ -60,7 +61,7 @@ export abstract class AbstractPickerComponent implements OnInit, OnChanges, OnDe protected destroyed$: Subject = new Subject(); protected isCustomPlaceHolder: boolean = false; - constructor(protected i18n: NzI18nService, protected cdr: ChangeDetectorRef, protected dateHelper: DateHelperService) { } + constructor(protected i18n: NzI18nService, protected cdr: ChangeDetectorRef, protected dateHelper: DateHelperService, public noAnimation: NzNoAnimationDirective) { } ngOnInit(): void { // Subscribe the every locale change if the nzLocale is not handled by user diff --git a/components/date-picker/date-picker.component.ts b/components/date-picker/date-picker.component.ts index f67335a4e9..f3fa11f2cc 100644 --- a/components/date-picker/date-picker.component.ts +++ b/components/date-picker/date-picker.component.ts @@ -4,13 +4,17 @@ import { ChangeDetectorRef, Component, ElementRef, + Host, + Optional, Renderer2, ViewEncapsulation } from '@angular/core'; import { NG_VALUE_ACCESSOR } from '@angular/forms'; -import { NzI18nService } from '../i18n/nz-i18n.service'; +import { NzNoAnimationDirective } from '../core/no-animation/nz-no-animation.directive'; import { DateHelperService } from '../i18n/date-helper.service'; +import { NzI18nService } from '../i18n/nz-i18n.service'; + import { DateRangePickerComponent } from './date-range-picker.component'; @Component({ @@ -28,8 +32,9 @@ import { DateRangePickerComponent } from './date-range-picker.component'; export class NzDatePickerComponent extends DateRangePickerComponent { isRange: boolean = false; - constructor(i18n: NzI18nService, cdr: ChangeDetectorRef, dateHelper: DateHelperService, renderer: Renderer2, elementRef: ElementRef) { - super(i18n, cdr, dateHelper); + constructor(i18n: NzI18nService, cdr: ChangeDetectorRef, dateHelper: DateHelperService, renderer: Renderer2, elementRef: ElementRef, + @Host() @Optional() public noAnimation: NzNoAnimationDirective) { + super(i18n, cdr, dateHelper, noAnimation); renderer.addClass(elementRef.nativeElement, 'ant-calendar-picker'); } } diff --git a/components/date-picker/date-picker.module.ts b/components/date-picker/date-picker.module.ts index efdeceeb0d..e82df0ceef 100644 --- a/components/date-picker/date-picker.module.ts +++ b/components/date-picker/date-picker.module.ts @@ -2,6 +2,7 @@ import { OverlayModule } from '@angular/cdk/overlay'; import { CommonModule } from '@angular/common'; import { NgModule } from '@angular/core'; +import { NzNoAnimationModule } from '../core/no-animation/nz-no-animation.module'; import { NzOverlayModule } from '../core/overlay/nz-overlay.module'; import { NzIconModule } from '../icon/nz-icon.module'; @@ -22,7 +23,8 @@ import { NzYearPickerComponent } from './year-picker.component'; OverlayModule, LibPackerModule, NzIconModule, - NzOverlayModule + NzOverlayModule, + NzNoAnimationModule ], exports: [ NzDatePickerComponent, diff --git a/components/date-picker/date-range-picker.component.html b/components/date-picker/date-range-picker.component.html index 89b61e6855..a333fb99d4 100644 --- a/components/date-picker/date-range-picker.component.html +++ b/components/date-picker/date-range-picker.component.html @@ -11,6 +11,7 @@ [placeholder]="nzPlaceHolder" [size]="nzSize" [style]="pickerStyle" + [noAnimation]="noAnimation?.nzNoAnimation" (openChange)="onOpenChange($event)" > | string; - constructor(i18n: NzI18nService, cdr: ChangeDetectorRef, dateHelper: DateHelperService) { - super(i18n, cdr, dateHelper); + constructor(i18n: NzI18nService, cdr: ChangeDetectorRef, dateHelper: DateHelperService, noAnimation: NzNoAnimationDirective) { + super(i18n, cdr, dateHelper, noAnimation); } ngOnInit(): void { diff --git a/components/date-picker/header-picker.component.html b/components/date-picker/header-picker.component.html index 42fd98e0d3..3c0c771a0a 100644 --- a/components/date-picker/header-picker.component.html +++ b/components/date-picker/header-picker.component.html @@ -11,6 +11,7 @@ [placeholder]="nzPlaceHolder" [size]="nzSize" [style]="nzStyle" + [noAnimation]="noAnimation?.nzNoAnimation" (openChange)="onOpenChange($event)" >
    diff --git a/components/date-picker/header-picker.component.ts b/components/date-picker/header-picker.component.ts index 8f64f9586b..c67f8ed941 100644 --- a/components/date-picker/header-picker.component.ts +++ b/components/date-picker/header-picker.component.ts @@ -1,5 +1,6 @@ import { ChangeDetectorRef, Component, Input, OnChanges, OnInit, SimpleChanges, TemplateRef } from '@angular/core'; +import { NzNoAnimationDirective } from '../core/no-animation/nz-no-animation.directive'; import { FunctionProp } from '../core/types/common-wrap'; import { valueFunctionProp } from '../core/util/convert'; import { DateHelperService } from '../i18n/date-helper.service'; @@ -28,8 +29,8 @@ export class HeaderPickerComponent extends AbstractPickerComponent implements On private supportPanels: PanelMode[]; - constructor(i18n: NzI18nService, cdr: ChangeDetectorRef, dateHelper: DateHelperService) { - super(i18n, cdr, dateHelper); + constructor(i18n: NzI18nService, cdr: ChangeDetectorRef, dateHelper: DateHelperService, noAnimation: NzNoAnimationDirective) { + super(i18n, cdr, dateHelper, noAnimation); } ngOnInit(): void { diff --git a/components/date-picker/month-picker.component.ts b/components/date-picker/month-picker.component.ts index d658208242..df6a448f32 100644 --- a/components/date-picker/month-picker.component.ts +++ b/components/date-picker/month-picker.component.ts @@ -4,11 +4,15 @@ import { ChangeDetectorRef, Component, ElementRef, + Host, Input, + Optional, Renderer2, ViewEncapsulation } from '@angular/core'; import { NG_VALUE_ACCESSOR } from '@angular/forms'; + +import { NzNoAnimationDirective } from '../core/no-animation/nz-no-animation.directive'; import { NzI18nService } from '../i18n/nz-i18n.service'; import { DateHelperService } from '../i18n/date-helper.service'; @@ -31,8 +35,9 @@ export class NzMonthPickerComponent extends HeaderPickerComponent { endPanelMode: SupportHeaderPanel = 'month'; - constructor(i18n: NzI18nService, cdr: ChangeDetectorRef, dateHelper: DateHelperService, renderer: Renderer2, elementRef: ElementRef) { - super(i18n, cdr, dateHelper); + constructor(i18n: NzI18nService, cdr: ChangeDetectorRef, dateHelper: DateHelperService, renderer: Renderer2, elementRef: ElementRef, + @Host() @Optional() public noAnimation: NzNoAnimationDirective) { + super(i18n, cdr, dateHelper, noAnimation); renderer.addClass(elementRef.nativeElement, 'ant-calendar-picker'); } } diff --git a/components/date-picker/picker.component.html b/components/date-picker/picker.component.html index 0f0e6fb69e..9f312ad10d 100644 --- a/components/date-picker/picker.component.html +++ b/components/date-picker/picker.component.html @@ -79,6 +79,7 @@ (detach)="onOverlayDetach()" >
    { nzClosable?: boolean; nzMaskClosable?: boolean; nzMask?: boolean; + nzNoAnimation?: boolean; nzTitle?: string | TemplateRef<{}>; nzContent?: TemplateRef<{ $implicit: D, drawerRef: NzDrawerRef }> | Type; nzContentParams?: D; diff --git a/components/drawer/nz-drawer-ref.ts b/components/drawer/nz-drawer-ref.ts index 9a06209f30..0f1632dc9a 100644 --- a/components/drawer/nz-drawer-ref.ts +++ b/components/drawer/nz-drawer-ref.ts @@ -11,6 +11,7 @@ export abstract class NzDrawerRef { abstract open(): void; abstract nzClosable: boolean; + abstract nzNoAnimation: boolean; abstract nzMaskClosable: boolean; abstract nzMask: boolean; abstract nzTitle: string | TemplateRef<{}>; diff --git a/components/drawer/nz-drawer.component.html b/components/drawer/nz-drawer.component.html index 91152abb2c..b4b8116c5f 100644 --- a/components/drawer/nz-drawer.component.html +++ b/components/drawer/nz-drawer.component.html @@ -1,6 +1,7 @@
    extends NzDrawerRef @Input() @InputBoolean() nzClosable = true; @Input() @InputBoolean() nzMaskClosable = true; @Input() @InputBoolean() nzMask = true; + @Input() @InputBoolean() nzNoAnimation = false; @Input() nzTitle: string | TemplateRef<{}>; @Input() nzPlacement: NzDrawerPlacement = 'right'; @Input() nzMaskStyle: object = {}; @@ -183,7 +184,7 @@ export class NzDrawerComponent extends NzDrawerRef setTimeout(() => { this.updateBodyOverflow(); this.restoreFocus(); - }, DRAWER_ANIMATE_DURATION); + }, this.getAnimationDuration()); } } } @@ -192,6 +193,10 @@ export class NzDrawerComponent extends NzDrawerRef this.disposeOverlay(); } + private getAnimationDuration(): number { + return this.nzNoAnimation ? 0 : DRAWER_ANIMATE_DURATION; + } + close(result?: R): void { this.isOpen = false; this.updateOverlayStyle(); @@ -201,7 +206,7 @@ export class NzDrawerComponent extends NzDrawerRef this.restoreFocus(); this.nzAfterClose.next(result); this.nzAfterClose.complete(); - }, DRAWER_ANIMATE_DURATION); + }, this.getAnimationDuration()); } open(): void { @@ -213,7 +218,7 @@ export class NzDrawerComponent extends NzDrawerRef this.changeDetectorRef.detectChanges(); setTimeout(() => { this.nzAfterOpen.next(); - }, DRAWER_ANIMATE_DURATION); + }, this.getAnimationDuration()); } closeClick(): void { diff --git a/components/drawer/nz-drawer.module.ts b/components/drawer/nz-drawer.module.ts index 875dff7d6f..45a8d89d0e 100644 --- a/components/drawer/nz-drawer.module.ts +++ b/components/drawer/nz-drawer.module.ts @@ -5,11 +5,13 @@ import { NgModule } from '@angular/core'; import { NzAddOnModule } from '../core/addon/addon.module'; import { NzIconModule } from '../icon/nz-icon.module'; +import { NzNoAnimationModule } from '../core/no-animation/nz-no-animation.module'; + import { NzDrawerComponent } from './nz-drawer.component'; import { NzDrawerService } from './nz-drawer.service'; @NgModule({ - imports : [ CommonModule, OverlayModule, PortalModule, NzIconModule, NzAddOnModule ], + imports : [ CommonModule, OverlayModule, PortalModule, NzIconModule, NzAddOnModule, NzNoAnimationModule ], exports : [ NzDrawerComponent ], declarations : [ NzDrawerComponent ], entryComponents: [ NzDrawerComponent ], diff --git a/components/drawer/nz-drawer.spec.ts b/components/drawer/nz-drawer.spec.ts index de67583453..361502378a 100644 --- a/components/drawer/nz-drawer.spec.ts +++ b/components/drawer/nz-drawer.spec.ts @@ -4,6 +4,7 @@ import { async, fakeAsync, inject, tick, ComponentFixture, TestBed } from '@angu import { OverlayContainer } from '@angular/cdk/overlay'; import { BrowserDynamicTestingModule } from '@angular/platform-browser-dynamic/testing'; +import { NoopAnimationsModule } from '@angular/platform-browser/animations'; import { NzDrawerRef } from './nz-drawer-ref'; import { NzDrawerComponent } from './nz-drawer.component'; import { NzDrawerModule } from './nz-drawer.module'; @@ -18,7 +19,7 @@ describe('NzDrawerComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - imports : [ NzDrawerModule ], + imports : [ NzDrawerModule, NoopAnimationsModule ], declarations: [ NzTestDrawerComponent ] }) .compileComponents(); diff --git a/components/dropdown/nz-dropdown-button.component.html b/components/dropdown/nz-dropdown-button.component.html index 6f729cae3f..95caf21372 100644 --- a/components/dropdown/nz-dropdown-button.component.html +++ b/components/dropdown/nz-dropdown-button.component.html @@ -29,6 +29,7 @@ (positionChange)="onPositionChange($event)" [cdkConnectedOverlayOpen]="nzVisible">
    (); @ViewChild(NzDropDownDirective) nzDropDownDirective: NzDropDownDirective; - constructor(cdr: ChangeDetectorRef, nzMenuDropdownService: NzMenuDropdownService) { - super(cdr, nzMenuDropdownService); + constructor(cdr: ChangeDetectorRef, nzMenuDropdownService: NzMenuDropdownService, + @Host() @Optional() public noAnimation: NzNoAnimationDirective) { + super(cdr, nzMenuDropdownService, noAnimation); } /** rewrite afterViewInit hook */ diff --git a/components/dropdown/nz-dropdown.component.html b/components/dropdown/nz-dropdown.component.html index 2f9b6f5d16..bea6ae221a 100644 --- a/components/dropdown/nz-dropdown.component.html +++ b/components/dropdown/nz-dropdown.component.html @@ -12,6 +12,7 @@ [ngClass]="nzOverlayClassName" [ngStyle]="nzOverlayStyle" [@slideMotion]="dropDownPosition" + [nzNoAnimation]="noAnimation?.nzNoAnimation" [style.minWidth.px]="triggerWidth" (mouseenter)="setVisibleStateWhen(true,'hover')" (mouseleave)="setVisibleStateWhen(false,'hover')"> diff --git a/components/dropdown/nz-dropdown.component.ts b/components/dropdown/nz-dropdown.component.ts index 568d0bdabf..b6c725a23b 100644 --- a/components/dropdown/nz-dropdown.component.ts +++ b/components/dropdown/nz-dropdown.component.ts @@ -5,10 +5,10 @@ import { ChangeDetectorRef, Component, ContentChild, - EventEmitter, + EventEmitter, Host, Input, OnChanges, - OnDestroy, + OnDestroy, Optional, Output, SimpleChanges, ViewChild, @@ -17,6 +17,7 @@ import { import { combineLatest, merge, EMPTY, Observable, Subject } from 'rxjs'; import { debounceTime, distinctUntilChanged, map, mapTo, takeUntil } from 'rxjs/operators'; import { slideMotion } from '../core/animation/slide'; +import { NzNoAnimationDirective } from '../core/no-animation/nz-no-animation.directive'; import { DEFAULT_DROPDOWN_POSITIONS, POSITION_MAP } from '../core/overlay/overlay-position'; import { InputBoolean } from '../core/util/convert'; import { NzMenuDirective } from '../menu/nz-menu.directive'; @@ -103,7 +104,8 @@ export class NzDropDownComponent implements OnDestroy, AfterContentInit, OnChang } } - constructor(protected cdr: ChangeDetectorRef, private nzMenuDropdownService: NzMenuDropdownService) { + constructor(protected cdr: ChangeDetectorRef, private nzMenuDropdownService: NzMenuDropdownService, + @Host() @Optional() public noAnimation: NzNoAnimationDirective) { } ngOnDestroy(): void { diff --git a/components/dropdown/nz-dropdown.module.ts b/components/dropdown/nz-dropdown.module.ts index 1ed5d8228f..06e943bf52 100644 --- a/components/dropdown/nz-dropdown.module.ts +++ b/components/dropdown/nz-dropdown.module.ts @@ -3,6 +3,8 @@ import { CommonModule } from '@angular/common'; import { NgModule } from '@angular/core'; import { FormsModule } from '@angular/forms'; +import { NzNoAnimationModule } from '../core/no-animation/nz-no-animation.module'; + import { NzButtonModule } from '../button/nz-button.module'; import { NzIconModule } from '../icon/nz-icon.module'; import { NzMenuModule } from '../menu/nz-menu.module'; @@ -13,7 +15,7 @@ import { NzDropDownComponent } from './nz-dropdown.component'; import { NzDropDownDirective } from './nz-dropdown.directive'; @NgModule({ - imports : [ CommonModule, OverlayModule, FormsModule, NzButtonModule, NzMenuModule, NzIconModule ], + imports : [ CommonModule, OverlayModule, FormsModule, NzButtonModule, NzMenuModule, NzIconModule, NzNoAnimationModule ], entryComponents: [ NzDropdownContextComponent ], declarations : [ NzDropDownComponent, NzDropDownButtonComponent, NzDropDownDirective, NzDropDownADirective, NzDropdownContextComponent ], exports : [ NzDropDownComponent, NzDropDownButtonComponent, NzDropDownDirective, NzDropDownADirective ] diff --git a/components/menu/nz-menu.module.ts b/components/menu/nz-menu.module.ts index 8b64624607..d5ee1bb96f 100644 --- a/components/menu/nz-menu.module.ts +++ b/components/menu/nz-menu.module.ts @@ -3,6 +3,8 @@ import { CommonModule } from '@angular/common'; import { NgModule } from '@angular/core'; import { FormsModule } from '@angular/forms'; +import { NzNoAnimationModule } from '../core/no-animation/nz-no-animation.module'; + import { NzButtonModule } from '../button/nz-button.module'; import { NzIconModule } from '../icon/nz-icon.module'; import { NzMenuDividerDirective } from '../menu/nz-menu-divider.directive'; @@ -12,7 +14,7 @@ import { NzMenuDirective } from '../menu/nz-menu.directive'; import { NzSubMenuComponent } from '../menu/nz-submenu.component'; @NgModule({ - imports : [ CommonModule, FormsModule, NzButtonModule, OverlayModule, NzIconModule ], + imports : [ CommonModule, FormsModule, NzButtonModule, OverlayModule, NzIconModule, NzNoAnimationModule ], declarations: [ NzMenuDirective, NzMenuItemDirective, NzSubMenuComponent, NzMenuDividerDirective, NzMenuGroupComponent ], exports : [ NzMenuDirective, NzMenuItemDirective, NzSubMenuComponent, NzMenuDividerDirective, NzMenuGroupComponent ] }) diff --git a/components/menu/nz-submenu.component.html b/components/menu/nz-submenu.component.html index 070bf65900..1c1444a6d4 100644 --- a/components/menu/nz-submenu.component.html +++ b/components/menu/nz-submenu.component.html @@ -12,7 +12,7 @@
    -
      +
      -
      +
      extends NzModalRef impleme @Input() @InputBoolean() nzCancelDisabled: boolean = false; @Input() @InputBoolean() nzCancelLoading: boolean = false; @Input() @InputBoolean() nzKeyboard: boolean = true; + @Input() @InputBoolean() nzNoAnimation = false; @Input() nzContent: string | TemplateRef<{}> | Type; // [STATIC] If not specified, will use @Input() nzComponentParams: T; // [STATIC] ONLY avaliable when nzContent is a component @Input() nzFooter: string | TemplateRef<{}> | Array>; // [STATIC] Default Modal ONLY @@ -381,7 +382,7 @@ export class NzModalComponent extends NzModalRef impleme return new Promise((resolve) => setTimeout(() => { // Return when animation is over this.changeAnimationState(null); resolve(); - }, MODAL_ANIMATE_DURATION)); + }, this.nzNoAnimation ? 0 : MODAL_ANIMATE_DURATION)); } private formatModalButtons(buttons: Array>): Array> { diff --git a/components/modal/nz-modal.module.ts b/components/modal/nz-modal.module.ts index 2f62a84def..2221f6aa0a 100644 --- a/components/modal/nz-modal.module.ts +++ b/components/modal/nz-modal.module.ts @@ -3,6 +3,7 @@ import { CommonModule } from '@angular/common'; import { NgModule } from '@angular/core'; import { NzButtonModule } from '../button/nz-button.module'; +import { NzNoAnimationModule } from '../core/no-animation/nz-no-animation.module'; import { LoggerModule } from '../core/util/logger/logger.module'; import { NzI18nModule } from '../i18n/nz-i18n.module'; import { NzIconModule } from '../icon/nz-icon.module'; @@ -13,7 +14,7 @@ import { NzModalComponent } from './nz-modal.component'; import { NzModalService } from './nz-modal.service'; @NgModule({ - imports : [ CommonModule, OverlayModule, NzI18nModule, NzButtonModule, LoggerModule, NzIconModule ], + imports : [ CommonModule, OverlayModule, NzI18nModule, NzButtonModule, LoggerModule, NzIconModule, NzNoAnimationModule ], exports : [ NzModalComponent ], declarations : [ NzModalComponent, CssUnitPipe ], entryComponents: [ NzModalComponent ], diff --git a/components/modal/nz-modal.type.ts b/components/modal/nz-modal.type.ts index ab6ffbeb57..52778fb0d2 100644 --- a/components/modal/nz-modal.type.ts +++ b/components/modal/nz-modal.type.ts @@ -40,6 +40,7 @@ export interface ModalOptions { // tslint:disable-line:no-any nzOnOk?: EventEmitter | OnClickCallback; // Mixed using ng's Input/Output (Should care of "this" when using OnClickCallback) nzCancelText?: string; nzCancelLoading?: boolean; + nzNoAnimation?: boolean; nzOnCancel?: EventEmitter | OnClickCallback; // Mixed using ng's Input/Output (Should care of "this" when using OnClickCallback) } diff --git a/components/ng-zorro-antd.module.ts b/components/ng-zorro-antd.module.ts index 4e8b5fca60..98cd439041 100644 --- a/components/ng-zorro-antd.module.ts +++ b/components/ng-zorro-antd.module.ts @@ -16,6 +16,7 @@ import { NzCascaderModule } from './cascader/nz-cascader.module'; import { NzCheckboxModule } from './checkbox/nz-checkbox.module'; import { NzCollapseModule } from './collapse/nz-collapse.module'; import { NzCommentModule } from './comment/nz-comment.module'; +import { NzNoAnimationModule } from './core/no-animation/nz-no-animation.module'; import { NzWaveModule } from './core/wave/nz-wave.module'; import { NzDatePickerModule } from './date-picker/date-picker.module'; import { NzDividerModule } from './divider/nz-divider.module'; @@ -121,6 +122,7 @@ export * from './time-picker'; export * from './version'; export * from './core/wave'; export * from './core/util'; +export * from './core/no-animation'; @NgModule({ exports: [ @@ -179,6 +181,7 @@ export * from './core/util'; NzTreeSelectModule, NzTimePickerModule, NzWaveModule, + NzNoAnimationModule, NzSkeletonModule, NzStatisticModule, NzEmptyModule diff --git a/components/popconfirm/nz-popconfirm.component.html b/components/popconfirm/nz-popconfirm.component.html index 6de3a0474f..3394b6c7e1 100644 --- a/components/popconfirm/nz-popconfirm.component.html +++ b/components/popconfirm/nz-popconfirm.component.html @@ -13,6 +13,7 @@
      diff --git a/components/popconfirm/nz-popconfirm.component.ts b/components/popconfirm/nz-popconfirm.component.ts index 0ffd44d039..e72679a105 100644 --- a/components/popconfirm/nz-popconfirm.component.ts +++ b/components/popconfirm/nz-popconfirm.component.ts @@ -3,12 +3,15 @@ import { ChangeDetectorRef, Component, EventEmitter, + Host, Input, + Optional, Output, TemplateRef, ViewEncapsulation } from '@angular/core'; import { zoomBigMotion } from '../core/animation/zoom'; +import { NzNoAnimationDirective } from '../core/no-animation/nz-no-animation.directive'; import { InputBoolean } from '../core/util/convert'; import { NzToolTipComponent } from '../tooltip/nz-tooltip.component'; @@ -39,8 +42,8 @@ export class NzPopconfirmComponent extends NzToolTipComponent { @Output() readonly nzOnCancel: EventEmitter = new EventEmitter(); @Output() readonly nzOnConfirm: EventEmitter = new EventEmitter(); - constructor(cdr: ChangeDetectorRef) { - super(cdr); + constructor(cdr: ChangeDetectorRef, @Host() @Optional() public noAnimation: NzNoAnimationDirective) { + super(cdr, noAnimation); } show(): void { diff --git a/components/popconfirm/nz-popconfirm.directive.ts b/components/popconfirm/nz-popconfirm.directive.ts index a443ca79a8..0d566f525f 100644 --- a/components/popconfirm/nz-popconfirm.directive.ts +++ b/components/popconfirm/nz-popconfirm.directive.ts @@ -3,7 +3,7 @@ import { ComponentFactoryResolver, Directive, ElementRef, - EventEmitter, + EventEmitter, Host, Input, OnInit, Optional, @@ -14,6 +14,7 @@ import { import { distinctUntilChanged } from 'rxjs/operators'; +import { NzNoAnimationDirective } from '../core/no-animation/nz-no-animation.directive'; import { InputBoolean } from '../core/util/convert'; import { NzTooltipDirective } from '../tooltip/nz-tooltip.directive'; import { NzPopconfirmComponent } from './nz-popconfirm.component'; @@ -57,15 +58,17 @@ export class NzPopconfirmDirective extends NzTooltipDirective implements OnInit hostView: ViewContainerRef, resolver: ComponentFactoryResolver, renderer: Renderer2, - @Optional() tooltip: NzPopconfirmComponent + @Optional() tooltip: NzPopconfirmComponent, + @Host() @Optional() public noAnimation: NzNoAnimationDirective ) { - super(elementRef, hostView, resolver, renderer, tooltip); + super(elementRef, hostView, resolver, renderer, tooltip, noAnimation); } ngOnInit(): void { if (!this.tooltip) { const tooltipComponent = this.hostView.createComponent(this.factory); this.tooltip = tooltipComponent.instance; + this.tooltip.noAnimation = this.noAnimation; // Remove element when use directive https://github.com/NG-ZORRO/ng-zorro-antd/issues/1967 this.renderer.removeChild(this.renderer.parentNode(this.elementRef.nativeElement), tooltipComponent.location.nativeElement); this.isDynamicTooltip = true; diff --git a/components/popconfirm/nz-popconfirm.module.ts b/components/popconfirm/nz-popconfirm.module.ts index 68df27f28c..07e2bc8d32 100644 --- a/components/popconfirm/nz-popconfirm.module.ts +++ b/components/popconfirm/nz-popconfirm.module.ts @@ -4,6 +4,7 @@ import { NgModule } from '@angular/core'; import { NzButtonModule } from '../button/nz-button.module'; import { NzAddOnModule } from '../core/addon/addon.module'; +import { NzNoAnimationModule } from '../core/no-animation/nz-no-animation.module'; import { NzOverlayModule } from '../core/overlay/nz-overlay.module'; import { NzI18nModule } from '../i18n/nz-i18n.module'; import { NzIconModule } from '../icon/nz-icon.module'; @@ -21,7 +22,8 @@ import { NzPopconfirmDirective } from './nz-popconfirm.directive'; NzI18nModule, NzIconModule, NzAddOnModule, - NzOverlayModule + NzOverlayModule, + NzNoAnimationModule ], entryComponents: [ NzPopconfirmComponent ] }) diff --git a/components/popover/nz-popover.component.html b/components/popover/nz-popover.component.html index e8abbefc77..8ca967d56e 100644 --- a/components/popover/nz-popover.component.html +++ b/components/popover/nz-popover.component.html @@ -13,6 +13,7 @@
      diff --git a/components/popover/nz-popover.component.ts b/components/popover/nz-popover.component.ts index 96e4b871b6..444ec16d7f 100644 --- a/components/popover/nz-popover.component.ts +++ b/components/popover/nz-popover.component.ts @@ -1,6 +1,17 @@ -import { ChangeDetectionStrategy, ChangeDetectorRef, Component, ContentChild, Input, TemplateRef, ViewEncapsulation } from '@angular/core'; +import { + ChangeDetectionStrategy, + ChangeDetectorRef, + Component, + ContentChild, + Host, + Input, + Optional, + TemplateRef, + ViewEncapsulation +} from '@angular/core'; import { zoomBigMotion } from '../core/animation/zoom'; +import { NzNoAnimationDirective } from '../core/no-animation/nz-no-animation.directive'; import { isNotNil } from '../core/util'; import { NzToolTipComponent } from '../tooltip/nz-tooltip.component'; @@ -24,8 +35,8 @@ export class NzPopoverComponent extends NzToolTipComponent { @Input() @ContentChild('neverUsedTemplate') nzTitle: string | TemplateRef; @Input() @ContentChild('nzTemplate') nzContent: string | TemplateRef; - constructor(cdr: ChangeDetectorRef) { - super(cdr); + constructor(cdr: ChangeDetectorRef, @Host() @Optional() public noAnimation: NzNoAnimationDirective) { + super(cdr, noAnimation); } protected isContentEmpty(): boolean { diff --git a/components/popover/nz-popover.directive.ts b/components/popover/nz-popover.directive.ts index a5b3f7a25e..27e6f1a904 100644 --- a/components/popover/nz-popover.directive.ts +++ b/components/popover/nz-popover.directive.ts @@ -3,10 +3,13 @@ import { ComponentFactoryResolver, Directive, ElementRef, + Host, Optional, Renderer2, ViewContainerRef } from '@angular/core'; + +import { NzNoAnimationDirective } from '../core/no-animation/nz-no-animation.directive'; import { NzTooltipDirective } from '../tooltip/nz-tooltip.directive'; import { NzPopoverComponent } from './nz-popover.component'; @@ -24,8 +27,9 @@ export class NzPopoverDirective extends NzTooltipDirective { hostView: ViewContainerRef, resolver: ComponentFactoryResolver, renderer: Renderer2, - @Optional() tooltip: NzPopoverComponent + @Optional() tooltip: NzPopoverComponent, + @Host() @Optional() public noAnimation: NzNoAnimationDirective ) { - super(elementRef, hostView, resolver, renderer, tooltip); + super(elementRef, hostView, resolver, renderer, tooltip, noAnimation); } } diff --git a/components/popover/nz-popover.module.ts b/components/popover/nz-popover.module.ts index 5429cd5252..80e7e7ac85 100644 --- a/components/popover/nz-popover.module.ts +++ b/components/popover/nz-popover.module.ts @@ -3,6 +3,7 @@ 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 { NzOverlayModule } from '../core/overlay/nz-overlay.module'; import { NzPopoverComponent } from './nz-popover.component'; @@ -12,7 +13,7 @@ import { NzPopoverDirective } from './nz-popover.directive'; entryComponents: [ NzPopoverComponent ], exports : [ NzPopoverDirective, NzPopoverComponent ], declarations : [ NzPopoverDirective, NzPopoverComponent ], - imports : [ CommonModule, OverlayModule, NzAddOnModule, NzOverlayModule ] + imports : [ CommonModule, OverlayModule, NzAddOnModule, NzOverlayModule, NzNoAnimationModule ] }) export class NzPopoverModule { diff --git a/components/select/nz-select-top-control.component.html b/components/select/nz-select-top-control.component.html index d78d34f8c0..d5fe4f43da 100644 --- a/components/select/nz-select-top-control.component.html +++ b/components/select/nz-select-top-control.component.html @@ -38,9 +38,10 @@
      • + [nzNoAnimation]="noAnimation?.nzNoAnimation" + [attr.title]="option.nzLabel" + [class.ant-select-selection__choice__disabled]="option.nzDisabled" + class="ant-select-selection__choice">
        {{ option.nzLabel }}
      • -
      • +
      • ` | - | | `(nzOnClose)` | Callback executed when tag is closed, only works when `nzMode="closable"`| `EventEmitter` | - | | `(nzCheckedChange)` | Checked status change call back, only works when `nzMode="checkable"` | `EventEmitter` | - | diff --git a/components/tag/doc/index.zh-CN.md b/components/tag/doc/index.zh-CN.md index 8ae43f8a1d..343010bb89 100644 --- a/components/tag/doc/index.zh-CN.md +++ b/components/tag/doc/index.zh-CN.md @@ -21,7 +21,6 @@ title: Tag | `[nzMode]` | 设定标签工作的模式 | `'closeable'|'default'|'checkable'` | `'default'` | | `[nzChecked]` | 设置标签的选中状态,可双向绑定,在 `nzMode="checkable"` 时可用 | `boolean` | `false` | | `[nzColor]` | 标签色 | `string` | - | -| `[nzNoAnimation]` | 是否禁用动画 | `boolean` | `false` | | `(nzAfterClose)` | 关闭动画完成后的回调,在 `nzMode="closable"` 时可用 | `EventEmitter` | - | | `(nzOnClose)` | 关闭时的回调,在 `nzMode="closable"` 时可用 | `EventEmitter` | - | | `(nzCheckedChange)` | 设置标签的选中状态的回调,在 `nzMode="checkable"` 时可用 | `EventEmitter` | - | diff --git a/components/tag/nz-tag.component.ts b/components/tag/nz-tag.component.ts index 09a1881bc9..ce00a2c5b1 100644 --- a/components/tag/nz-tag.component.ts +++ b/components/tag/nz-tag.component.ts @@ -25,7 +25,6 @@ import { InputBoolean } from '../core/util/convert'; encapsulation : ViewEncapsulation.None, host : { '[@fadeMotion]' : '', - '[@.disabled]' : 'nzNoAnimation', '(@fadeMotion.done)' : 'afterAnimation($event)', '(click)' : 'updateCheckedStatus()', '[style.background-color]': 'presetColor? null : nzColor' diff --git a/components/tooltip/nz-tooltip.component.html b/components/tooltip/nz-tooltip.component.html index 321c898ef8..6cce85fe37 100644 --- a/components/tooltip/nz-tooltip.component.html +++ b/components/tooltip/nz-tooltip.component.html @@ -14,6 +14,7 @@ class="ant-tooltip" [ngClass]="_classMap" [ngStyle]="nzOverlayStyle" + [nzNoAnimation]="noAnimation?.nzNoAnimation" [@zoomBigMotion]="'active'" (@zoomBigMotion.done)="_afterVisibilityAnimation($event)">
        diff --git a/components/tooltip/nz-tooltip.component.ts b/components/tooltip/nz-tooltip.component.ts index 9a577be843..b94dc2a01b 100644 --- a/components/tooltip/nz-tooltip.component.ts +++ b/components/tooltip/nz-tooltip.component.ts @@ -11,8 +11,10 @@ import { Component, ContentChild, EventEmitter, + Host, Input, OnChanges, + Optional, Output, TemplateRef, ViewChild, @@ -20,6 +22,7 @@ import { } from '@angular/core'; import { BehaviorSubject, Observable } from 'rxjs'; import { zoomBigMotion } from '../core/animation/zoom'; +import { NzNoAnimationDirective } from '../core/no-animation/nz-no-animation.directive'; import { getPlacementName, DEFAULT_TOOLTIP_POSITIONS, POSITION_MAP } from '../core/overlay/overlay-position'; import { isNotNil } from '../core/util/check'; import { toBoolean } from '../core/util/convert'; @@ -91,7 +94,7 @@ export class NzToolTipComponent implements OnChanges { @Output() readonly nzVisibleChange = new EventEmitter(); - constructor(public cdr: ChangeDetectorRef) { + constructor(public cdr: ChangeDetectorRef, @Host() @Optional() public noAnimation: NzNoAnimationDirective) { } ngOnChanges(): void { diff --git a/components/tooltip/nz-tooltip.directive.ts b/components/tooltip/nz-tooltip.directive.ts index f318040580..2e3dbd8657 100644 --- a/components/tooltip/nz-tooltip.directive.ts +++ b/components/tooltip/nz-tooltip.directive.ts @@ -5,6 +5,7 @@ import { Directive, ElementRef, EventEmitter, + Host, Input, OnChanges, OnDestroy, @@ -20,6 +21,7 @@ import { import { Subscription } from 'rxjs'; import { distinctUntilChanged } from 'rxjs/operators'; +import { NzNoAnimationDirective } from '../core/no-animation/nz-no-animation.directive'; import { isNotNil } from '../core/util/check'; import { NzToolTipComponent } from './nz-tooltip.component'; @@ -74,7 +76,8 @@ export class NzTooltipDirective implements AfterViewInit, OnChanges, OnInit, OnD public hostView: ViewContainerRef, public resolver: ComponentFactoryResolver, public renderer: Renderer2, - @Optional() public tooltip: NzToolTipComponent + @Optional() public tooltip: NzToolTipComponent, + @Host() @Optional() public noAnimation: NzNoAnimationDirective ) { } @@ -87,6 +90,7 @@ export class NzTooltipDirective implements AfterViewInit, OnChanges, OnInit, OnD if (!this.tooltip) { const tooltipComponent = this.hostView.createComponent(this.factory); this.tooltip = tooltipComponent.instance; + this.tooltip.noAnimation = this.noAnimation; // Remove element when use directive https://github.com/NG-ZORRO/ng-zorro-antd/issues/1967 this.renderer.removeChild(this.renderer.parentNode(this.elementRef.nativeElement), tooltipComponent.location.nativeElement); this.isDynamicTooltip = true; diff --git a/components/tooltip/nz-tooltip.module.ts b/components/tooltip/nz-tooltip.module.ts index ea1332b386..6eb2776f36 100644 --- a/components/tooltip/nz-tooltip.module.ts +++ b/components/tooltip/nz-tooltip.module.ts @@ -3,6 +3,7 @@ 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 { NzOverlayModule } from '../core/overlay/nz-overlay.module'; // NOTE: the `t` is not uppercase in directive. Change this would however introduce break change. import { NzToolTipComponent } from './nz-tooltip.component'; @@ -11,7 +12,7 @@ import { NzTooltipDirective } from './nz-tooltip.directive'; @NgModule({ declarations : [ NzToolTipComponent, NzTooltipDirective ], exports : [ NzToolTipComponent, NzTooltipDirective ], - imports : [ CommonModule, OverlayModule, NzAddOnModule, NzOverlayModule ], + imports : [ CommonModule, OverlayModule, NzAddOnModule, NzOverlayModule, NzNoAnimationModule ], entryComponents: [ NzToolTipComponent ] }) export class NzToolTipModule { diff --git a/components/tree-select/nz-tree-select.component.html b/components/tree-select/nz-tree-select.component.html index 9b55236e3c..4a7f6db7b8 100644 --- a/components/tree-select/nz-tree-select.component.html +++ b/components/tree-select/nz-tree-select.component.html @@ -24,6 +24,7 @@ (positionChange)="onPositionChange($event)">
      • diff --git a/components/tree-select/nz-tree-select.component.ts b/components/tree-select/nz-tree-select.component.ts index 7165087e5e..9edf40c26b 100644 --- a/components/tree-select/nz-tree-select.component.ts +++ b/components/tree-select/nz-tree-select.component.ts @@ -10,10 +10,12 @@ import { Component, ElementRef, EventEmitter, + Host, Input, OnChanges, OnDestroy, OnInit, + Optional, Output, Renderer2, SimpleChanges, @@ -31,6 +33,7 @@ import { filter, tap } from 'rxjs/operators'; import { slideMotion } from '../core/animation/slide'; import { zoomMotion } from '../core/animation/zoom'; +import { NzNoAnimationDirective } from '../core/no-animation/nz-no-animation.directive'; import { NzSizeLDSType } from '../core/types/size'; import { InputBoolean } from '../core/util/convert'; import { NzFormatEmitEvent } from '../tree/interface'; @@ -155,7 +158,8 @@ export class NzTreeSelectComponent implements ControlValueAccessor, OnInit, OnDe private renderer: Renderer2, private cdr: ChangeDetectorRef, private nzTreeService: NzTreeSelectService, - private elementRef: ElementRef) { + private elementRef: ElementRef, + @Host() @Optional() public noAnimation: NzNoAnimationDirective) { this.renderer.addClass(this.elementRef.nativeElement, 'ant-select'); } diff --git a/components/tree-select/nz-tree-select.module.ts b/components/tree-select/nz-tree-select.module.ts index d983d2b0c4..3d8b0f0b21 100644 --- a/components/tree-select/nz-tree-select.module.ts +++ b/components/tree-select/nz-tree-select.module.ts @@ -2,6 +2,7 @@ import { OverlayModule } from '@angular/cdk/overlay'; import { CommonModule } from '@angular/common'; import { NgModule } from '@angular/core'; import { FormsModule } from '@angular/forms'; +import { NzNoAnimationModule } from '../core/no-animation/nz-no-animation.module'; import { NzOverlayModule } from '../core/overlay/nz-overlay.module'; import { NzEmptyModule } from '../empty/nz-empty.module'; import { NzIconModule } from '../icon/nz-icon.module'; @@ -9,7 +10,7 @@ import { NzTreeModule } from '../tree/nz-tree.module'; import { NzTreeSelectComponent } from './nz-tree-select.component'; @NgModule({ - imports : [ CommonModule, OverlayModule, FormsModule, NzTreeModule, NzIconModule, NzEmptyModule, NzOverlayModule ], + imports : [ CommonModule, OverlayModule, FormsModule, NzTreeModule, NzIconModule, NzEmptyModule, NzOverlayModule, NzNoAnimationModule ], declarations: [ NzTreeSelectComponent ], exports : [ NzTreeSelectComponent ] }) diff --git a/components/tree/nz-tree-node.component.html b/components/tree/nz-tree-node.component.html index 2318caef91..a71c9ab346 100644 --- a/components/tree/nz-tree-node.component.html +++ b/components/tree/nz-tree-node.component.html @@ -70,11 +70,12 @@ [class.ant-tree-child-tree-open]="nzTreeNode.isExpanded" [attr.data-expanded]="nzTreeNode.isExpanded" [ngClass]="nzNodeChildrenClass" - [@.disabled]="nzNoAnimation" + [@.disabled]="noAnimation?.nzNoAnimation" [@nodeState]="nzTreeNode.isExpanded ? 'active' : 'inactive'"> ; @Input() nzBeforeDrop: (confirm: NzFormatBeforeDropEvent) => Observable; @@ -450,7 +452,8 @@ export class NzTreeNodeComponent implements OnInit, OnChanges, OnDestroy { }); } - constructor(private nzTreeService: NzTreeBaseService, private ngZone: NgZone, private renderer: Renderer2, private elRef: ElementRef) { + constructor(private nzTreeService: NzTreeBaseService, private ngZone: NgZone, private renderer: Renderer2, private elRef: ElementRef, + @Host() @Optional() public noAnimation: NzNoAnimationDirective) { } ngOnInit(): void { diff --git a/components/tree/nz-tree.component.html b/components/tree/nz-tree.component.html index d8352a5381..683de90ab0 100644 --- a/components/tree/nz-tree.component.html +++ b/components/tree/nz-tree.component.html @@ -19,7 +19,7 @@ [nzExpandAll]="nzExpandAll" [nzDefaultExpandAll]="nzDefaultExpandAll" [nzTreeTemplate]="nzTreeTemplate" - [nzNoAnimation]="nzNoAnimation" + [nzNoAnimation]="noAnimation?.nzNoAnimation" (clickNode)="nzClick.emit($event)" (dblClick)="nzDblClick.emit($event)" (contextMenu)="nzContextMenu.emit($event)" diff --git a/components/tree/nz-tree.component.ts b/components/tree/nz-tree.component.ts index eebe39ad63..1617329c0f 100644 --- a/components/tree/nz-tree.component.ts +++ b/components/tree/nz-tree.component.ts @@ -3,16 +3,20 @@ import { Component, ContentChild, EventEmitter, + Host, Input, OnChanges, OnDestroy, OnInit, Optional, Output, - SimpleChange, SkipSelf, TemplateRef + SimpleChange, + SkipSelf, + TemplateRef } from '@angular/core'; import { NG_VALUE_ACCESSOR } from '@angular/forms'; import { Observable, ReplaySubject, Subscription } from 'rxjs'; +import { NzNoAnimationDirective } from '../core/no-animation/nz-no-animation.directive'; import { isNotNil } from '../core/util/check'; import { InputBoolean } from '../core/util/convert'; import { NzTreeSelectService } from '../tree-select/nz-tree-select.service'; @@ -61,7 +65,6 @@ export class NzTreeComponent implements OnInit, OnChanges, OnDestroy { @Input() @InputBoolean() nzMultiple = false; @Input() @InputBoolean() nzExpandAll: boolean = false; @Input() @InputBoolean() nzHideUnMatched = false; - @Input() @InputBoolean() nzNoAnimation = false; @Input() @InputBoolean() nzSelectMode = false; /** @@ -239,7 +242,7 @@ export class NzTreeComponent implements OnInit, OnChanges, OnDestroy { this.onTouched = fn; } - constructor(public nzTreeService: NzTreeBaseService) { + constructor(public nzTreeService: NzTreeBaseService, @Host() @Optional() public noAnimation: NzNoAnimationDirective) { } ngOnInit(): void { diff --git a/components/tree/nz-tree.module.ts b/components/tree/nz-tree.module.ts index af9aca7d59..7ee53fcfcb 100644 --- a/components/tree/nz-tree.module.ts +++ b/components/tree/nz-tree.module.ts @@ -1,5 +1,6 @@ import { CommonModule } from '@angular/common'; import { NgModule } from '@angular/core'; +import { NzNoAnimationModule } from '../core/no-animation/nz-no-animation.module'; import { NzIconModule } from '../icon/nz-icon.module'; import { NzTreeNodeComponent } from './nz-tree-node.component'; import { NzTreeComponent } from './nz-tree.component'; @@ -7,7 +8,8 @@ import { NzTreeComponent } from './nz-tree.component'; @NgModule({ imports : [ CommonModule, - NzIconModule + NzIconModule, + NzNoAnimationModule ], declarations: [ NzTreeComponent, diff --git a/docs/animations.en-US.md b/docs/animations.en-US.md new file mode 100644 index 0000000000..b8ba4cabd9 --- /dev/null +++ b/docs/animations.en-US.md @@ -0,0 +1,71 @@ +--- +order: 6 +title: Animations Switch +--- + +NG-ZORRO allows developers to turn off animations. You can set animations by adding corresponding directive or +configurations, or use global configuration to turn off all animations with. + +### In Global + +Replace `BrowserAnimationsModule` with 'NoopAnimationsModule` in the your module. + +```ts +@NgModule({ + imports : [ + ..., + NoopAnimationsModule + ] +}) +``` + +### In Templates + +Add the nzNoAnimation property to the component that wants to close the animation. + +```HTML + +
          + +``` + +### In Services + +Add the following configuration to the component that wants to close the animation. + +#### Modal, Drawer + +```ts +{ + ..., + nzNoAnimation: true +} +``` + +#### Notification, Message + +```ts +{ + ..., + nzAnimate: false +} +``` + +### Turn-Off the Wave Effect + +Some component use dynamic style to support wave effect, You can set the provider `NZ_WAVE_GLOBAL_CONFIG` Or use + `NoopAnimationsModule` to turn off the wave effect. + +```ts +@NgModule({ + ... + providers : [ + ..., + { + provide: NZ_WAVE_GLOBAL_CONFIG, useValue: { + disabled: true + } + } + ] +}) +``` \ No newline at end of file diff --git a/docs/animations.zh-CN.md b/docs/animations.zh-CN.md new file mode 100644 index 0000000000..8c46451b83 --- /dev/null +++ b/docs/animations.zh-CN.md @@ -0,0 +1,70 @@ +--- +order: 6 +title: 动画开关 +--- + +NG-ZORRO 允许开发者关闭动画效果,您可以通过添加对应指令或者配置来设置动画的开关,也可以通过全局配置关闭所有动画。 + +### 在全局关闭 + +在模块中使用 `NoopAnimationsModule` 替换 `BrowserAnimationsModule`。 + +```ts +@NgModule({ + imports : [ + ..., + NoopAnimationsModule + ] +}) +``` + +### 在模版中关闭 + +在想关闭动画的组件上添加 nzNoAnimation 属性。 + +```HTML + +
            + +``` + +### 在服务中关闭 + +在调用组件服务时传入以下配置来关闭动画。 + +#### Modal, Drawer + +```ts +{ + ..., + nzNoAnimation: true +} +``` + +#### Notification, Message + +```ts +{ + ..., + nzAnimate: false +} +``` + +### 关闭波浪效果 + +部分组件(如:Button)为了支持波纹效果,使用了动态样式,因此无法直接使用样式覆盖。但是你可以通过设置提供商 `NZ_WAVE_GLOBAL_CONFIG` +或者使用 `NoopAnimationsModule` 来关闭波浪效果。 + +```ts +@NgModule({ + ... + providers : [ + ..., + { + provide: NZ_WAVE_GLOBAL_CONFIG, useValue: { + disabled: true + } + } + ] +}) +``` \ No newline at end of file