fix(lazy-loading): improve image loading performance with lazy loading and low priority fetch (#431)
* fix(lazy-loading): improve image loading performance with lazy loading and low priority fetch * fix(styles): update intrinsic size for virtual scroller items to use CSS variable * refactor(book-card): simplify redundant cover width binding Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --------- Co-authored-by: Zach <zachyale@gmail.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
This commit is contained in:
co-authored by
coderabbitai[bot]
Zach
parent
bff20c5219
commit
2c26bd26fd
@@ -440,6 +440,8 @@
|
||||
padding: 1rem;
|
||||
box-sizing: border-box;
|
||||
overflow-y: auto;
|
||||
will-change: scroll-position;
|
||||
overflow-anchor: none;
|
||||
|
||||
@media (width <= 768px) {
|
||||
height: calc(100dvh - 9rem);
|
||||
@@ -452,6 +454,7 @@
|
||||
column-gap: 21px;
|
||||
align-items: start;
|
||||
width: 100%;
|
||||
contain: layout style;
|
||||
|
||||
// Mobile: fixed 2 or 3 columns based on phone width
|
||||
@media (width <= 767px) {
|
||||
@@ -463,7 +466,9 @@
|
||||
.virtual-scroller-item {
|
||||
position: relative;
|
||||
margin-bottom: 21px; // Whole px to avoid parseInt truncation in ngx-virtual-scroller
|
||||
transition: width 0.2s ease, height 0.2s ease;
|
||||
contain: strict;
|
||||
content-visibility: auto;
|
||||
contain-intrinsic-size: auto var(--virtual-scroller-item-height, 220px);
|
||||
|
||||
@media (width <= 767px) {
|
||||
margin-bottom: 0.5rem;
|
||||
|
||||
+4
-1
@@ -12,8 +12,11 @@
|
||||
class="book-cover"
|
||||
[class.square-cover]="_isAudiobook || useSquareCovers"
|
||||
[alt]="('book.card.alt.cover' | transloco: { title: displayTitle })"
|
||||
width="250"
|
||||
[height]="(_isAudiobook || useSquareCovers) ? 250 : 350"
|
||||
loading="lazy"
|
||||
decoding="async"/>
|
||||
decoding="async"
|
||||
fetchpriority="low"/>
|
||||
} @else {
|
||||
<app-cover-placeholder class="book-cover" [class.square-cover]="_isAudiobook || useSquareCovers" [title]="book.metadata?.title ?? ''" [author]="(book.metadata?.authors ?? []).join(', ')" />
|
||||
}
|
||||
|
||||
+1
-6
@@ -7,7 +7,7 @@
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
box-shadow: 0 2px 8px rgb(0 0 0 / 15%);
|
||||
transition: box-shadow 0.25s ease, transform 0.25s ease;
|
||||
contain: layout style;
|
||||
|
||||
&:hover {
|
||||
box-shadow: 0 8px 24px rgb(0 0 0 / 30%);
|
||||
@@ -45,11 +45,6 @@
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
border-radius: 8px 8px 0 0;
|
||||
transition: transform 0.35s ease;
|
||||
}
|
||||
|
||||
.book-card:hover .book-cover {
|
||||
transform: scale(1.04);
|
||||
}
|
||||
|
||||
.book-cover.square-cover {
|
||||
|
||||
+6
-2
@@ -1,4 +1,4 @@
|
||||
import {ChangeDetectionStrategy, ChangeDetectorRef, Component, ElementRef, EventEmitter, inject, Input, OnChanges, OnInit, Output, SimpleChanges, ViewChild} from '@angular/core';
|
||||
import {ChangeDetectionStrategy, ChangeDetectorRef, Component, ElementRef, EventEmitter, inject, Input, OnChanges, OnDestroy, OnInit, Output, SimpleChanges, ViewChild} from '@angular/core';
|
||||
import {TooltipModule} from "primeng/tooltip";
|
||||
import {AdditionalFile, Book, BookType, ReadStatus} from '../../../model/book.model';
|
||||
import {Button} from 'primeng/button';
|
||||
@@ -38,7 +38,7 @@ import {QueryClient} from '@tanstack/angular-query-experimental';
|
||||
standalone: true,
|
||||
changeDetection: ChangeDetectionStrategy.OnPush
|
||||
})
|
||||
export class BookCardComponent implements OnInit, OnChanges {
|
||||
export class BookCardComponent implements OnInit, OnChanges, OnDestroy {
|
||||
|
||||
@Output() checkboxClick = new EventEmitter<{ index: number; book: Book; selected: boolean; shiftKey: boolean }>();
|
||||
@Output() menuToggled = new EventEmitter<boolean>();
|
||||
@@ -117,6 +117,10 @@ export class BookCardComponent implements OnInit, OnChanges {
|
||||
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
this._coverImageUrl = null;
|
||||
}
|
||||
|
||||
ngOnChanges(changes: SimpleChanges): void {
|
||||
if (changes['book'] || changes['forceEbookMode'] || changes['useSquareCovers']) {
|
||||
this.computeAllMemoizedValues();
|
||||
|
||||
+5
-1
@@ -4,7 +4,11 @@
|
||||
[src]="coverUrl"
|
||||
class="book-cover"
|
||||
alt="Cover of {{ book.metadata?.title }}"
|
||||
loading="lazy"/>
|
||||
width="250"
|
||||
height="350"
|
||||
loading="lazy"
|
||||
decoding="async"
|
||||
fetchpriority="low"/>
|
||||
} @else {
|
||||
<app-cover-placeholder class="book-cover" [title]="book.metadata?.title ?? ''" [author]="(book.metadata?.authors ?? []).join(', ')" size="sm" />
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user