1
0
mirror of https://github.com/xuthus83/pigallery2.git synced 2024-11-03 21:04:03 +08:00

Treating NaN aspect ratio as 1 (square): fixes grid alignment mismatch fixes #625

This commit is contained in:
Patrik J. Braun 2023-03-02 00:00:37 +01:00
parent 117d9e3093
commit 64acc27727
3 changed files with 4 additions and 5 deletions

View File

@ -71,6 +71,6 @@ export const MediaDTOUtils = {
}, },
calcAspectRatio: (photo: MediaDTO): number => { calcAspectRatio: (photo: MediaDTO): number => {
return photo.metadata.size.width / photo.metadata.size.height; return (photo.metadata.size.width / photo.metadata.size.height) || 1; // NaN should be treated as square photo
}, },
}; };

View File

@ -57,7 +57,7 @@ export class GridRowBuilder {
let width = 0; let width = 0;
for (const item of this.photoRow) { for (const item of this.photoRow) {
const size = item.metadata.size; const size = item.metadata.size;
width += size.width / size.height; // summing up aspect ratios width += (size.width / size.height) || 1; // summing up aspect ratios, NaN should be treated as square photo
} }
const height = const height =
(this.containerWidth - (this.containerWidth -

View File

@ -5,8 +5,7 @@
[gridMedia]="gridPhoto" [gridMedia]="gridPhoto"
[style.width.px]="gridPhoto.renderWidth" [style.width.px]="gridPhoto.renderWidth"
[style.height.px]="gridPhoto.renderHeight" [style.height.px]="gridPhoto.renderHeight"
[style.marginLeft.px]="IMAGE_MARGIN" [style.margin-left.px]="IMAGE_MARGIN"
[style.marginRight.px]="IMAGE_MARGIN"> [style.margin-right.px]="IMAGE_MARGIN">
</app-gallery-grid-photo> </app-gallery-grid-photo>
</div> </div>