From 19442e25efdd7062ed3676830993888ef0ea8f20 Mon Sep 17 00:00:00 2001 From: Fedor Katurov Date: Fri, 8 Nov 2019 12:27:17 +0700 Subject: [PATCH] fixed minimum image height --- src/components/node/NodeImageSlideBlock/index.tsx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/components/node/NodeImageSlideBlock/index.tsx b/src/components/node/NodeImageSlideBlock/index.tsx index 20df25b1..e4e846a6 100644 --- a/src/components/node/NodeImageSlideBlock/index.tsx +++ b/src/components/node/NodeImageSlideBlock/index.tsx @@ -79,15 +79,16 @@ const NodeImageSlideBlock: FC = ({ node, is_loading, updateLayout }) => if (!wrap || !wrap.current) return; const { width } = wrap.current.getBoundingClientRect(); + const fallback = (width * 9) / 16; - if (is_loading) return setHeight((width * 9) / 16); + if (is_loading) return setHeight(fallback); const selected = Math.abs(-offset / width); - if (!heights[Math.round(selected)]) return setHeight((width * 9) / 16); + if (!heights[Math.round(selected)]) return setHeight(fallback); - const prev = Math.max(heights[Math.floor(selected)] || 320, 320); - const next = Math.max(heights[Math.ceil(selected)] || 320, 320); + const prev = Math.max(heights[Math.floor(selected)] || fallback, fallback); + const next = Math.max(heights[Math.ceil(selected)] || fallback, fallback); const now = prev - (prev - next) * (selected % 1); if (current !== Math.round(selected)) setCurrent(Math.round(selected));