From 000391f8d060db6619fb308a5069000889a4a012 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 11 Sep 2024 07:44:37 +0530 Subject: [PATCH] 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) --- src/pyj/read_book/scrollbar.pyj | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/pyj/read_book/scrollbar.pyj b/src/pyj/read_book/scrollbar.pyj index 2d7fcfb3cb..498cef2eff 100644 --- a/src/pyj/read_book/scrollbar.pyj +++ b/src/pyj/read_book/scrollbar.pyj @@ -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)