From 7e49092f177ec51a15eb173d4d8cfd9660b730db Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 6 Oct 2019 22:51:54 +0530 Subject: [PATCH] Move scrollbar suppression into the load pipeline and only suppress until load is completed --- src/pyj/read_book/iframe.pyj | 4 ++++ src/pyj/read_book/resources.pyj | 1 + src/pyj/read_book/settings.pyj | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/pyj/read_book/iframe.pyj b/src/pyj/read_book/iframe.pyj index 5551bebd32..67a0887a20 100644 --- a/src/pyj/read_book/iframe.pyj +++ b/src/pyj/read_book/iframe.pyj @@ -260,6 +260,10 @@ class IframeBoss: self.content_loaded_stage2() def content_loaded_stage2(self): + # this is the loading styles used to suppress scrollbars during load + # added in unserialize_html + document.head.firstChild.textContent = '' + self.connect_links() self.content_ready = True csi = current_spine_item() diff --git a/src/pyj/read_book/resources.pyj b/src/pyj/read_book/resources.pyj index 05cdf617e0..37aa49699b 100644 --- a/src/pyj/read_book/resources.pyj +++ b/src/pyj/read_book/resources.pyj @@ -239,6 +239,7 @@ def unserialize_html(serialized_data, proceed, postprocess_dom): head, body = tree[1], tree[2] # noqa: unused-local clear(document.head, document.body) remove_all_attributes(document.head, document.body) + document.head.appendChild(E.style(type='text/css', 'html::-webkit-scrollbar, body::-webkit-scrollbar { display: none !important }')) # Default stylesheet if not runtime.is_standalone_viewer: # for the standalone viewer the default font family is set diff --git a/src/pyj/read_book/settings.pyj b/src/pyj/read_book/settings.pyj index 4d137b2dfe..01c840ce2f 100644 --- a/src/pyj/read_book/settings.pyj +++ b/src/pyj/read_book/settings.pyj @@ -45,7 +45,7 @@ def apply_colors(): else: text = '' - ss.textContent = text + '\n\nhtml::-webkit-scrollbar, body::-webkit-scrollbar { display: none !important }' + ss.textContent = text def apply_stylesheet():