From b0a869b7ed93d9f8a40ad23f118d9876e729be53 Mon Sep 17 00:00:00 2001 From: John Factotum <50942278+johnfactotum@users.noreply.github.com> Date: Wed, 20 Mar 2024 08:44:47 +0800 Subject: [PATCH] Fix page end cut off when starting with page break Fixes https://github.com/johnfactotum/foliate/issues/1179 --- paginator.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/paginator.js b/paginator.js index 4eefbd1..f5be2ec 100644 --- a/paginator.js +++ b/paginator.js @@ -311,7 +311,13 @@ class View { if (this.#column) { const side = this.#vertical ? 'height' : 'width' const otherSide = this.#vertical ? 'width' : 'height' - const contentSize = this.#contentRange.getBoundingClientRect()[side] + const contentRect = this.#contentRange.getBoundingClientRect() + const rootRect = this.document.documentElement.getBoundingClientRect() + // offset caused by column break at the start of the page + // which seem to be supported only by WebKit and only for horizontal writing + const contentStart = this.#vertical ? 0 + : this.#rtl ? rootRect.right - contentRect.right : contentRect.left - rootRect.left + const contentSize = contentStart + contentRect[side] const pageCount = Math.ceil(contentSize / this.#size) const expandedSize = pageCount * this.#size this.#element.style.padding = '0'