Skip to content

Commit

Permalink
refactor: change small logic
Browse files Browse the repository at this point in the history
  • Loading branch information
splincode committed Sep 19, 2024
1 parent 5ce088a commit 6aaff81
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions projects/kit/directives/lazy-loading/lazy-loading.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
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 {
Expand Down

0 comments on commit 6aaff81

Please sign in to comment.