Make scrollbar sync to contents use last reported position

This commit is contained in:
Kovid Goyal 2025-04-13 09:15:01 +05:30
parent 55898fcfaa
commit d2320b6505
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -104,13 +104,14 @@ class BookScrollbar:
frac = max(0, min(frac, 1)) frac = max(0, min(frac, 1))
c.firstChild.style.top = f'{frac * (c.clientHeight - c.firstChild.clientHeight)}px' 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.sync_to_contents_timer = 0
self.set_position(frac) self.set_position(self.sync_to_contents_frac)
def sync_to_contents(self, frac): def sync_to_contents(self, frac):
self.sync_to_contents_frac = frac
if not self.sync_to_contents_timer: 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): def apply_color_scheme(self, colors):
fg = cached_color_to_rgba(colors.foreground) fg = cached_color_to_rgba(colors.foreground)