Fix NaN media height error
This commit is contained in:
parent
42f39d6aae
commit
606356246a
1 changed files with 7 additions and 10 deletions
|
@ -285,18 +285,15 @@ class MediaGallery extends React.PureComponent {
|
||||||
const width = this.state.width || defaultWidth;
|
const width = this.state.width || defaultWidth;
|
||||||
const aspectRatio = media.getIn([0, 'meta', 'small', 'aspect']);
|
const aspectRatio = media.getIn([0, 'meta', 'small', 'aspect']);
|
||||||
|
|
||||||
const style = {};
|
const getHeight = () => {
|
||||||
|
if (!aspectRatio) return width*9/16;
|
||||||
if (isPanoramic(aspectRatio)) {
|
if (isPanoramic(aspectRatio)) return Math.floor(width / maximumAspectRatio);
|
||||||
style.height = Math.floor(width / maximumAspectRatio);
|
if (isPortrait(aspectRatio)) return Math.floor(width / minimumAspectRatio);
|
||||||
} else if (isPortrait(aspectRatio)) {
|
return Math.floor(width / aspectRatio);
|
||||||
style.height = Math.floor(width / minimumAspectRatio);
|
};
|
||||||
} else {
|
|
||||||
style.height = Math.floor(width / aspectRatio);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ImmutableMap({
|
return ImmutableMap({
|
||||||
style,
|
style: { height: getHeight() },
|
||||||
itemsDimensions: [],
|
itemsDimensions: [],
|
||||||
size: 1,
|
size: 1,
|
||||||
width,
|
width,
|
||||||
|
|
Loading…
Reference in a new issue