From c345691c1dee0c69df8b2e98da7479ede633dab3 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 22 Mar 2020 10:34:11 +0530 Subject: [PATCH] Viewer: Ensure there is no bleed between pages when using single page per screen --- src/pyj/read_book/paged_mode.pyj | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/pyj/read_book/paged_mode.pyj b/src/pyj/read_book/paged_mode.pyj index d5d31e6c15..f120a49aac 100644 --- a/src/pyj/read_book/paged_mode.pyj +++ b/src/pyj/read_book/paged_mode.pyj @@ -59,9 +59,12 @@ def create_page_div(elem): _in_paged_mode = False def in_paged_mode(): return _in_paged_mode + + col_width = screen_width = screen_height = cols_per_screen = gap = col_and_gap = number_of_cols = last_scrolled_to_column = 0 is_full_screen_layout = False + def reset_paged_mode_globals(): nonlocal _in_paged_mode, col_width, col_and_gap, screen_height, gap, screen_width, is_full_screen_layout, cols_per_screen, number_of_cols, last_scrolled_to_column scroll_viewport.reset_globals() @@ -197,12 +200,12 @@ def layout(is_single_page, on_resize): # Calculate the column width so that cols_per_screen columns fit exactly in # the window width, with their separator margins ww = col_width = screen_width = scroll_viewport.width() - gap = 0 + sm = opts.margin_left + opts.margin_right + gap = sm if n > 1: # Adjust the side margin so that the window width satisfies # col_width * n + (n-1) * 2 * side_margin = window_width - sm = opts.margin_left + opts.margin_right - gap = sm + ((ww + sm) % n) # Ensure ww + gap is a multiple of n + gap += ((ww + sm) % n) # Ensure ww + gap is a multiple of n col_width = ((ww + gap) // n) - gap screen_height = scroll_viewport.height()