mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Viewer: Fix viewer flickering when scrollbar is enabled and the header/footer is too wide for the screen.
This commit is contained in:
parent
b1dbedaab0
commit
bc0c9c1fcc
@ -9,6 +9,9 @@ from book_list.theme import cached_color_to_rgba
|
||||
from dom import unique_id
|
||||
|
||||
|
||||
SIZE = 10
|
||||
|
||||
|
||||
class BookScrollbar:
|
||||
|
||||
def __init__(self, view):
|
||||
@ -27,10 +30,10 @@ class BookScrollbar:
|
||||
self.on_bob_mouseup = self.on_bob_mouse_event.bind(None, 'up')
|
||||
return E.div(
|
||||
id=self.container_id,
|
||||
style='height: 100vh; background-color: #aaa; width: 10px; border-radius: 5px',
|
||||
style=f'height: 100vh; background-color: #aaa; width: {SIZE}px; border-radius: 5px',
|
||||
onclick=self.bar_clicked,
|
||||
E.div(
|
||||
style='position: relative; width: 100%; height: 22px; background-color: #444; border-radius: 5px',
|
||||
style=f'position: relative; width: 100%; height: {int(2.2*SIZE)}px; background-color: #444; border-radius: 5px',
|
||||
onmousedown=self.on_bob_mousedown,
|
||||
),
|
||||
E.div(
|
||||
@ -82,6 +85,10 @@ class BookScrollbar:
|
||||
sd = get_session_data()
|
||||
self.container.style.display = 'block' if sd.get('book_scrollbar') else 'none'
|
||||
|
||||
@property
|
||||
def effective_width(self):
|
||||
return SIZE if self.container.style.display is 'block' else 0
|
||||
|
||||
def set_position(self, frac):
|
||||
c = self.container
|
||||
frac = max(0, min(frac, 1))
|
||||
|
@ -507,8 +507,9 @@ class View:
|
||||
if which is 'left':
|
||||
# Explicitly set the width of the central panel. This is needed
|
||||
# on small screens with chrome, without it sometimes the right
|
||||
# margin goes off the screen.
|
||||
m.nextSibling.style.maxWidth = 'calc(100vw - {}px)'.format(margin_left + margin_right)
|
||||
# margin/scrollbar goes off the screen.
|
||||
m.nextSibling.style.maxWidth = 'calc(100vw - {}px)'.format(
|
||||
margin_left + margin_right + self.book_scrollbar.effective_width)
|
||||
set_css(m, width=val + 'px')
|
||||
val = min(val, 25)
|
||||
m.firstChild.style.width = val + 'px'
|
||||
|
Loading…
x
Reference in New Issue
Block a user