From d2320b65054778fc3dc6a39f29b7d1dd7e8b710c Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 13 Apr 2025 09:15:01 +0530 Subject: [PATCH] Make scrollbar sync to contents use last reported position --- src/pyj/read_book/scrollbar.pyj | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/pyj/read_book/scrollbar.pyj b/src/pyj/read_book/scrollbar.pyj index 498cef2eff..f042679852 100644 --- a/src/pyj/read_book/scrollbar.pyj +++ b/src/pyj/read_book/scrollbar.pyj @@ -104,13 +104,14 @@ 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): + def _sync_to_contents(self): self.sync_to_contents_timer = 0 - self.set_position(frac) + self.set_position(self.sync_to_contents_frac) def sync_to_contents(self, frac): + self.sync_to_contents_frac = frac if not self.sync_to_contents_timer: - self.sync_to_contents_timer = window.setTimeout(self._sync_to_contents.bind(None, frac), 50) + self.sync_to_contents_timer = window.setTimeout(self._sync_to_contents, 50) def apply_color_scheme(self, colors): fg = cached_color_to_rgba(colors.foreground)