From ae583cf2a9a2c12f099811c63c67886a651fe76d Mon Sep 17 00:00:00 2001 From: tr7zw Date: Tue, 7 Jun 2022 16:09:02 +0200 Subject: [PATCH] Workaround for "0 width/height" api responses This needs a more proper fix probably. --- public/js/reader.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/public/js/reader.js b/public/js/reader.js index a5d8e6b..11b3b49 100644 --- a/public/js/reader.js +++ b/public/js/reader.js @@ -29,14 +29,14 @@ const readerComponent = () => { return { id: i + 1, url: `${base_url}api/page/${tid}/${eid}/${i+1}`, - width: d.width, - height: d.height, + width: d.width == 0 ? "100%" : d.width, + height: d.height == 0 ? "100%" : d.height, }; }); - const avgRatio = this.items.reduce((acc, cur) => { + const avgRatio = dimensions.reduce((acc, cur) => { return acc + cur.height / cur.width - }, 0) / this.items.length; + }, 0) / dimensions.length; console.log(avgRatio); this.longPages = avgRatio > 2;