mirror of
https://github.com/Raghu-Ch/angular-challenges.git
synced 2026-02-11 21:33:02 -05:00
feat(challenge33): about performance
This commit is contained in:
1
libs/shared/directives/src/index.ts
Normal file
1
libs/shared/directives/src/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from './lib/cd-flashing.directive';
|
||||
23
libs/shared/directives/src/lib/cd-flashing.directive.ts
Normal file
23
libs/shared/directives/src/lib/cd-flashing.directive.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
/* eslint-disable @angular-eslint/directive-selector */
|
||||
import { Directive, DoCheck, ElementRef, NgZone } from '@angular/core';
|
||||
|
||||
@Directive({
|
||||
selector: '[cd-flash]',
|
||||
standalone: true,
|
||||
})
|
||||
export class CDFlashingDirective implements DoCheck {
|
||||
constructor(private elementRef: ElementRef, private zone: NgZone) {}
|
||||
|
||||
ngDoCheck(): void {
|
||||
this.cdRan();
|
||||
}
|
||||
|
||||
public cdRan(): void {
|
||||
this.zone.runOutsideAngular(() => {
|
||||
this.elementRef.nativeElement.classList.add('!bg-orange-500');
|
||||
setTimeout(() => {
|
||||
this.elementRef.nativeElement.classList.remove('!bg-orange-500');
|
||||
}, 1000);
|
||||
});
|
||||
}
|
||||
}
|
||||
8
libs/shared/directives/src/test-setup.ts
Normal file
8
libs/shared/directives/src/test-setup.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
// @ts-expect-error https://thymikee.github.io/jest-preset-angular/docs/getting-started/test-environment
|
||||
globalThis.ngJest = {
|
||||
testEnvironmentOptions: {
|
||||
errorOnUnknownElements: true,
|
||||
errorOnUnknownProperties: true,
|
||||
},
|
||||
};
|
||||
import 'jest-preset-angular/setup-jest';
|
||||
Reference in New Issue
Block a user