From 67fdbf97e5483c5a0c4fc123b632160a330de0f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Fri, 6 Aug 2021 09:17:00 +0200 Subject: [PATCH] Round percentageOfViewport MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- src/components/views/messages/TextualBody.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/views/messages/TextualBody.tsx b/src/components/views/messages/TextualBody.tsx index 969caccaee..83fe7f5a3d 100644 --- a/src/components/views/messages/TextualBody.tsx +++ b/src/components/views/messages/TextualBody.tsx @@ -136,7 +136,8 @@ export default class TextualBody extends React.Component { private addCodeExpansionButton(div: HTMLDivElement, pre: HTMLPreElement): void { // Calculate how many percent does the pre element take up. // If it's less than 30% we don't add the expansion button. - const percentageOfViewport = pre.offsetHeight / UIStore.instance.windowHeight * 100; + // We also round the number as it sometimes can be 29.99... + const percentageOfViewport = Math.round(pre.offsetHeight / UIStore.instance.windowHeight * 100); if (percentageOfViewport < 30) return; const button = document.createElement("span");