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:
parent
117d9e3093
commit
64acc27727
@ -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
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -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 -
|
||||||
|
@ -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>
|
||||||
|
Loading…
Reference in New Issue
Block a user