From 5bf261244dfffa99e6140515042f11fa4a99e042 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 15 Dec 2019 10:12:05 +0530 Subject: [PATCH] Viewer: Fix flick scrolling in flow mode jumping to next chapter. Fixes #1856398 [Unable to scroll on touchscreen in e-book viewer](https://bugs.launchpad.net/calibre/+bug/1856398) --- src/pyj/read_book/flow_mode.pyj | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/pyj/read_book/flow_mode.pyj b/src/pyj/read_book/flow_mode.pyj index a54178ee5b..5946dc6c90 100644 --- a/src/pyj/read_book/flow_mode.pyj +++ b/src/pyj/read_book/flow_mode.pyj @@ -98,13 +98,15 @@ def flow_onwheel(evt): dx = (scroll_viewport.width() - 30) * evt.deltaX if dx: window.scrollBy(dx, 0) - elif dy: + elif Math.abs(dy) >= 1: scroll_by(dy) smooth_y_data = {'last_event_at':0, 'up': False, 'timer':None, 'source':'wheel', 'pixels_per_ms': 0.2, 'scroll_interval':10, 'stop_scrolling_after':100} def do_y_scroll(): - if scroll_by((-1 if smooth_y_data.up else 1) * smooth_y_data.pixels_per_ms * smooth_y_data.scroll_interval): + dy = (-1 if smooth_y_data.up else 1) * smooth_y_data.pixels_per_ms * smooth_y_data.scroll_interval + if Math.abs(dy) >= 1: + scroll_by(dy) if Date.now() - smooth_y_data.last_event_at < smooth_y_data.stop_scrolling_after: smooth_y_data.timer = setTimeout(do_y_scroll, smooth_y_data.scroll_interval) @@ -218,10 +220,11 @@ def handle_gesture(gesture): if gesture.type is 'swipe': if gesture.points.length > 1 and not gesture.is_held: delta = gesture.points[-2] - gesture.points[-1] - if gesture.axis is 'vertical': - scroll_by(delta) - else: - window.scrollBy(delta, 0) + if Math.abs(delta) >= 1: + if gesture.axis is 'vertical': + scroll_by(delta) + else: + window.scrollBy(delta, 0) if not gesture.active and not gesture.is_held: flick_animator.start(gesture) elif gesture.type is 'prev-page':