mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Viewer: prevent flash of unstyled text while loading individual HTML files
This commit is contained in:
parent
dfdf3e113a
commit
0bf8898ca4
@ -262,15 +262,17 @@ class IframeBoss:
|
||||
self.do_layout(self.is_titlepage)
|
||||
if self.mathjax:
|
||||
return apply_mathjax(self.mathjax, self.book.manifest.link_uid, self.content_loaded_stage2)
|
||||
self.content_loaded_stage2()
|
||||
window.setTimeout(self.content_loaded_stage2, 1000)
|
||||
# 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
|
||||
# this is the loading styles used to suppress scrollbars during load
|
||||
# added in unserialize_html and the overlay to hide flash of unstyled
|
||||
# text
|
||||
document.body.removeChild(document.body.firstChild)
|
||||
|
||||
csi = current_spine_item()
|
||||
if csi.initial_position:
|
||||
ipos = csi.initial_position
|
||||
|
@ -236,7 +236,13 @@ 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 }'))
|
||||
# prevent flash of unstyled text during loading, showing
|
||||
# a blank background instead
|
||||
document.body.appendChild(E.div(
|
||||
'\xa0',
|
||||
style=f'position: absolute; z-index: 2147483647; width: 10000vw; height: 10000vh; background-color: {opts.color_scheme.background}',
|
||||
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user