mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-04-07 10:36:41 +00:00
Lazy loading images
This commit is contained in:
parent
98df9cd2b7
commit
c431d163c2
@ -26,7 +26,7 @@
|
||||
<div class="wrapper">
|
||||
<div class="buttonWrapper" *ngFor="let symbol of filteredSymbols | filenamefilter: searchText">
|
||||
<button [ngClass]="{ buttonSelected: isSelected === symbol.symbol_id }" class="button" (click)="setSelected(symbol.symbol_id)">
|
||||
<img [ngClass]="{ imageSelected: isSelected === symbol.symbol_id }" class="image" [src]="getImageSourceForTemplate(symbol.symbol_id)"/>
|
||||
<img lazyimg [ngClass]="{ imageSelected: isSelected === symbol.symbol_id }" class="image" [src]="getImageSourceForTemplate(symbol.symbol_id)"/>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
12
src/app/directives/LazyImg.directive.ts
Normal file
12
src/app/directives/LazyImg.directive.ts
Normal file
@ -0,0 +1,12 @@
|
||||
import { Directive, ElementRef } from '@angular/core';
|
||||
|
||||
@Directive({ selector: '[lazyimg]' })
|
||||
export class LazyImgDirective {
|
||||
constructor({ nativeElement }: ElementRef<HTMLImageElement>) {
|
||||
const supports = 'loading' in HTMLImageElement.prototype;
|
||||
|
||||
if (supports) {
|
||||
nativeElement.setAttribute('loading', 'lazy');
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user