diff --git a/src/pyj/read_book/iframe.pyj b/src/pyj/read_book/iframe.pyj index 29f85b712a..d40fe152f4 100644 --- a/src/pyj/read_book/iframe.pyj +++ b/src/pyj/read_book/iframe.pyj @@ -21,7 +21,7 @@ from read_book.paged_mode import ( onwheel as paged_onwheel, onkeydown as paged_onkeydown, scroll_to_elem, jump_to_cfi as paged_jump_to_cfi, handle_gesture as paged_handle_gesture, scroll_by_page as paged_scroll_by_page, anchor_funcs as paged_anchor_funcs, - snap_to_selection + snap_to_selection, reset_paged_mode_globals ) from read_book.settings import apply_settings, opts from read_book.touch import create_handlers as create_touch_handlers @@ -112,6 +112,7 @@ class IframeBoss: self.book = current_book.book = data.book spine = self.book.manifest.spine index = spine.indexOf(data.name) + reset_paged_mode_globals() set_layout_mode('flow' if FORCE_FLOW_MODE else data.settings.read_mode) if current_layout_mode() is 'flow': self.do_layout = flow_layout diff --git a/src/pyj/read_book/paged_mode.pyj b/src/pyj/read_book/paged_mode.pyj index 0f70d8c3dd..db58d9ce44 100644 --- a/src/pyj/read_book/paged_mode.pyj +++ b/src/pyj/read_book/paged_mode.pyj @@ -52,6 +52,11 @@ def in_paged_mode(): col_width = screen_width = screen_height = cols_per_screen = gap = col_and_gap = 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 + col_width = screen_width = screen_height = cols_per_screen = gap = col_and_gap = 0 + is_full_screen_layout = _in_paged_mode = False + def column_at(xpos): # Return the (zero-based) number of the column that contains xpos sw = document.body.scrollWidth