Skip to content

Commit

Permalink
fix fomatting
Browse files Browse the repository at this point in the history
  • Loading branch information
eneajaho committed Aug 20, 2024
1 parent f99ab66 commit ad05599
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { ChangeDetectionStrategy, Component, ViewEncapsulation } from '@angular/core';
import {
ChangeDetectionStrategy,
Component,
ViewEncapsulation,
} from '@angular/core';
import { AsyncPipe } from '@angular/common';

import { FastSvgComponent } from '@push-based/ngx-fast-svg';
Expand Down
37 changes: 17 additions & 20 deletions packages/ngx-fast-lib/src/lib/fast-svg.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ export class FastSvgComponent implements AfterViewInit, OnDestroy {

private readonly getImg = createGetImgFn(this.renderer);


name = input<string>('');
size = input<string>(this.registry.defaultSize);
width = input<string>('');
Expand Down Expand Up @@ -186,25 +185,23 @@ export class FastSvgComponent implements AfterViewInit, OnDestroy {
// This potentially could already receive the svg from the cache and drop the img from the DOM before it gets activated for lazy loading.
// NOTICE:
// If the svg is already cached the following code will execute synchronously. This gives us the chance to add
const sub = this.registry
.svgCache$(name)
.subscribe((cache) => {
// The first child is the `use` tag. The value of href gets displayed as SVG
svg.children[0].setAttribute('href', cache.name);
svg.setAttribute('viewBox', cache.viewBox);

// early exit no image
if (!img) return;

// If the img is present
// and the name in included in the href (svg is fully loaded, not only the suspense svg)
// Remove the element from the DOM as it is no longer needed
if (cache.name.includes(name)) {
img.removeEventListener('load', this.loadedListener);
// removeEventListener.bind(img, 'load', this.loadedListener);
img.remove();
}
});
const sub = this.registry.svgCache$(name).subscribe((cache) => {
// The first child is the `use` tag. The value of href gets displayed as SVG
svg.children[0].setAttribute('href', cache.name);
svg.setAttribute('viewBox', cache.viewBox);

// early exit no image
if (!img) return;

// If the img is present
// and the name in included in the href (svg is fully loaded, not only the suspense svg)
// Remove the element from the DOM as it is no longer needed
if (cache.name.includes(name)) {
img.removeEventListener('load', this.loadedListener);
// removeEventListener.bind(img, 'load', this.loadedListener);
img.remove();
}
});

// SSR
if (isPlatformServer(this.platform)) {
Expand Down

0 comments on commit ad05599

Please sign in to comment.