From 9acaa5616ee30b74524c00686a75277ebf612467 Mon Sep 17 00:00:00 2001 From: splincode Date: Thu, 19 Sep 2024 12:40:47 +0300 Subject: [PATCH] refactor: change small logic --- .../lazy-loading/lazy-loading.directive.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/projects/kit/directives/lazy-loading/lazy-loading.directive.ts b/projects/kit/directives/lazy-loading/lazy-loading.directive.ts index a52fe80f30847..3a348b33f671d 100644 --- a/projects/kit/directives/lazy-loading/lazy-loading.directive.ts +++ b/projects/kit/directives/lazy-loading/lazy-loading.directive.ts @@ -26,14 +26,17 @@ export class TuiImgLazyLoading { protected animation = signal('tuiSkeletonVibe ease-in-out 1s infinite alternate'); protected background = signal('var(--tui-background-neutral-2)'); - protected readonly $ = this.loading$ - .pipe(takeUntilDestroyed()) - .subscribe((src) => this.src.set(src)); + protected readonly $ = this.supported + ? null + : this.loading$.pipe(takeUntilDestroyed()).subscribe((src) => this.src.set(src)); @Input('src') public set srcSetter(src: SafeResourceUrl | string) { - this.src.set(this.supported ? src : null); - this.loading$.next(src); + if (this.supported) { + this.src.set(src); + } else { + this.loading$.next(src); + } } protected unset(): void {