mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Viewer: Fix stopping autoscroll at end of chapter not stopping next chapter jump. Fixes #1863487 [Clicking "Stop auto scroll" doesn't work when about to change chapter](https://bugs.launchpad.net/calibre/+bug/1863487)
This commit is contained in:
parent
8655121e16
commit
b99756d862
@ -236,6 +236,7 @@ class ScrollAnimator:
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.animation_id = None
|
self.animation_id = None
|
||||||
self.auto = False
|
self.auto = False
|
||||||
|
self.auto_timer = None
|
||||||
|
|
||||||
def is_running(self):
|
def is_running(self):
|
||||||
return self.animation_id is not None
|
return self.animation_id is not None
|
||||||
@ -246,7 +247,7 @@ class ScrollAnimator:
|
|||||||
|
|
||||||
now = window.performance.now()
|
now = window.performance.now()
|
||||||
self.end_time = now + self.DURATION
|
self.end_time = now + self.DURATION
|
||||||
clearTimeout(self.auto_timer)
|
self.stop_auto_timer()
|
||||||
|
|
||||||
if not self.is_running() or direction is not self.direction or auto is not self.auto:
|
if not self.is_running() or direction is not self.direction or auto is not self.auto:
|
||||||
if self.auto and not auto:
|
if self.auto and not auto:
|
||||||
@ -299,6 +300,7 @@ class ScrollAnimator:
|
|||||||
self.pause()
|
self.pause()
|
||||||
if opts.scroll_auto_boundary_delay >= 0:
|
if opts.scroll_auto_boundary_delay >= 0:
|
||||||
self.auto_timer = setTimeout(def():
|
self.auto_timer = setTimeout(def():
|
||||||
|
self.auto_timer = None
|
||||||
get_boss().send_message('next_spine_item', previous=self.direction is DIRECTION.Up)
|
get_boss().send_message('next_spine_item', previous=self.direction is DIRECTION.Up)
|
||||||
, opts.scroll_auto_boundary_delay * 1000)
|
, opts.scroll_auto_boundary_delay * 1000)
|
||||||
else:
|
else:
|
||||||
@ -324,6 +326,12 @@ class ScrollAnimator:
|
|||||||
window.cancelAnimationFrame(self.animation_id)
|
window.cancelAnimationFrame(self.animation_id)
|
||||||
self.animation_id = None
|
self.animation_id = None
|
||||||
self.report()
|
self.report()
|
||||||
|
self.stop_auto_timer()
|
||||||
|
|
||||||
|
def stop_auto_timer(self):
|
||||||
|
if self.auto_timer is not None:
|
||||||
|
clearTimeout(self.auto_timer)
|
||||||
|
self.auto_timer = None
|
||||||
|
|
||||||
def pause(self):
|
def pause(self):
|
||||||
if self.auto:
|
if self.auto:
|
||||||
@ -448,6 +456,7 @@ def auto_scroll_action(action):
|
|||||||
elif action is 'stop':
|
elif action is 'stop':
|
||||||
if is_auto_scroll_active():
|
if is_auto_scroll_active():
|
||||||
toggle_autoscroll()
|
toggle_autoscroll()
|
||||||
|
scroll_animator.stop_auto_timer()
|
||||||
elif action is 'resume':
|
elif action is 'resume':
|
||||||
auto_scroll_resume()
|
auto_scroll_resume()
|
||||||
return is_auto_scroll_active()
|
return is_auto_scroll_active()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user