forked from NG-ZORRO/ng-zorro-antd
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(module:all): support disable animations in every components (NG-…
…ZORRO#2975) * feat(module:all): support disable animations in every components close NG-ZORRO#2401, close NG-ZORRO#2922 * feat(module:no-animation): use `ANIMATION_MODULE_TYPE` as the second condition * build: fix build error * docs(module:animatons): add animations docs * test(module:drawer): fix test
- Loading branch information
Showing
75 changed files
with
492 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './public-api'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { coerceElement } from '@angular/cdk/coercion'; | ||
import { AfterViewInit, Directive, ElementRef, Inject, Input, OnChanges, Optional, Renderer2 } from '@angular/core'; | ||
import { ANIMATION_MODULE_TYPE } from '@angular/platform-browser/animations'; | ||
import { InputBoolean } from '../util/convert'; | ||
|
||
const DISABLED_CLASSNAME = 'nz-animate-disabled'; | ||
|
||
@Directive({ | ||
selector: '[nzNoAnimation]', | ||
host : { | ||
'[@.disabled]': 'nzNoAnimation' | ||
} | ||
}) | ||
export class NzNoAnimationDirective implements OnChanges, AfterViewInit { | ||
|
||
@Input() @InputBoolean() nzNoAnimation: boolean = false; | ||
|
||
constructor(private element: ElementRef, | ||
private renderer: Renderer2, | ||
@Optional() @Inject(ANIMATION_MODULE_TYPE) private animationType: string) { | ||
} | ||
|
||
ngOnChanges(): void { | ||
this.updateClass(); | ||
} | ||
|
||
ngAfterViewInit(): void { | ||
this.updateClass(); | ||
} | ||
|
||
private updateClass(): void { | ||
const element = coerceElement(this.element); | ||
if (!element) { return; } | ||
if (this.nzNoAnimation || this.animationType === 'NoopAnimations') { | ||
this.renderer.addClass(element, DISABLED_CLASSNAME); | ||
} else { | ||
this.renderer.removeClass(element, DISABLED_CLASSNAME); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { CommonModule } from '@angular/common'; | ||
import { NzNoAnimationDirective } from './nz-no-animation.directive'; | ||
|
||
@NgModule({ | ||
declarations: [ NzNoAnimationDirective ], | ||
exports : [ NzNoAnimationDirective ], | ||
imports : [ CommonModule ] | ||
}) | ||
export class NzNoAnimationModule { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export { NzNoAnimationModule } from './nz-no-animation.module'; | ||
export { NzNoAnimationDirective } from './nz-no-animation.directive'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.