E-book viewer: Fix scrollbar position not updating during continuous scroll. Fixes #2077801 [[Enhancement] Ebook-viewer: scrollbar slider position should be updated when scrolling the text](https://bugs.launchpad.net/calibre/+bug/2077801)

This commit is contained in:
Kovid Goyal 2024-09-11 07:44:37 +05:30
parent e80fdf55b7
commit 000391f8d0
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -104,10 +104,13 @@ class BookScrollbar:
frac = max(0, min(frac, 1))
c.firstChild.style.top = f'{frac * (c.clientHeight - c.firstChild.clientHeight)}px'
def _sync_to_contents(self, frac):
self.sync_to_contents_timer = 0
self.set_position(frac)
def sync_to_contents(self, frac):
if self.sync_to_contents_timer:
window.clearTimeout(self.sync_to_contents_timer)
self.sync_to_contents_timer = window.setTimeout(self.set_position.bind(None, frac), 100)
if not self.sync_to_contents_timer:
self.sync_to_contents_timer = window.setTimeout(self._sync_to_contents.bind(None, frac), 50)
def apply_color_scheme(self, colors):
fg = cached_color_to_rgba(colors.foreground)