mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
Fix looping hold timer due to missing touch end event on content loaded
This commit is contained in:
parent
b3b2317e98
commit
01c64414a7
@ -44,7 +44,8 @@ from read_book.shortcuts import (
|
|||||||
create_shortcut_map, keyevent_as_shortcut, shortcut_for_key_event
|
create_shortcut_map, keyevent_as_shortcut, shortcut_for_key_event
|
||||||
)
|
)
|
||||||
from read_book.toc import update_visible_toc_anchors
|
from read_book.toc import update_visible_toc_anchors
|
||||||
from read_book.touch import create_handlers as create_touch_handlers
|
from read_book.touch import (create_handlers as create_touch_handlers,
|
||||||
|
reset_handlers as reset_touch_handlers)
|
||||||
from read_book.viewport import scroll_viewport
|
from read_book.viewport import scroll_viewport
|
||||||
from utils import (
|
from utils import (
|
||||||
apply_cloned_selection, clone_selection, debounce, html_escape, is_ios
|
apply_cloned_selection, clone_selection, debounce, html_escape, is_ios
|
||||||
@ -334,6 +335,8 @@ class IframeBoss:
|
|||||||
self.send_message('content_loaded', progress_frac=self.calculate_progress_frac(), file_progress_frac=progress_frac())
|
self.send_message('content_loaded', progress_frac=self.calculate_progress_frac(), file_progress_frac=progress_frac())
|
||||||
self.last_cfi = None
|
self.last_cfi = None
|
||||||
self.auto_scroll_action('resume')
|
self.auto_scroll_action('resume')
|
||||||
|
reset_touch_handlers() # Needed to mitigate issue https://bugs.chromium.org/p/chromium/issues/detail?id=464579
|
||||||
|
|
||||||
window.setTimeout(self.update_cfi, 0)
|
window.setTimeout(self.update_cfi, 0)
|
||||||
window.setTimeout(self.update_toc_position, 0)
|
window.setTimeout(self.update_toc_position, 0)
|
||||||
|
|
||||||
|
@ -140,6 +140,12 @@ class TouchHandler:
|
|||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def reset_handlers(self):
|
||||||
|
self.stop_hold_timer()
|
||||||
|
self.ongoing_touches = {}
|
||||||
|
self.gesture_id = None
|
||||||
|
self.handled_tap_hold = False
|
||||||
|
|
||||||
def start_hold_timer(self):
|
def start_hold_timer(self):
|
||||||
self.stop_hold_timer()
|
self.stop_hold_timer()
|
||||||
self.hold_timer = window.setTimeout(self.check_for_hold, 100)
|
self.hold_timer = window.setTimeout(self.check_for_hold, 100)
|
||||||
@ -199,9 +205,7 @@ class TouchHandler:
|
|||||||
self.prune_expired_touches()
|
self.prune_expired_touches()
|
||||||
if not self.has_active_touches:
|
if not self.has_active_touches:
|
||||||
self.dispatch_gesture()
|
self.dispatch_gesture()
|
||||||
self.ongoing_touches = {}
|
self.reset_handlers()
|
||||||
self.gesture_id = None
|
|
||||||
self.handled_tap_hold = False
|
|
||||||
|
|
||||||
def handle_touchcancel(self, ev):
|
def handle_touchcancel(self, ev):
|
||||||
ev.preventDefault(), ev.stopPropagation()
|
ev.preventDefault(), ev.stopPropagation()
|
||||||
@ -279,6 +283,9 @@ def create_handlers():
|
|||||||
# on window instead of document
|
# on window instead of document
|
||||||
install_handlers(document, main_touch_handler)
|
install_handlers(document, main_touch_handler)
|
||||||
|
|
||||||
|
def reset_handlers():
|
||||||
|
main_touch_handler.reset_handlers()
|
||||||
|
|
||||||
def set_left_margin_handler(elem):
|
def set_left_margin_handler(elem):
|
||||||
install_handlers(elem, left_margin_handler)
|
install_handlers(elem, left_margin_handler)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user