Fix scroll by page always scrolling forward in flow mode

This commit is contained in:
Kovid Goyal 2019-08-30 06:53:16 +05:30
parent fa93b0d605
commit 566bfe6df2
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -57,7 +57,7 @@ def _check_for_scroll_end(func, obj, args, report):
before = window.pageYOffset
func.apply(obj, args)
if window.pageYOffset is before:
get_boss().send_message('next_spine_item', previous=arguments[0] < 0)
get_boss().send_message('next_spine_item', previous=args[0] < 0)
return False
if report:
report_human_scroll(window.pageYOffset - before)
@ -121,9 +121,9 @@ def goto_boundary(y):
@check_for_scroll_end_and_report
def scroll_by_page(backward):
def scroll_by_page(direction):
h = scroll_viewport.height() - 10
window.scrollBy(0, -h if backward else h)
window.scrollBy(0, h * direction)
def handle_shortcut(sc_name, evt):
@ -152,10 +152,10 @@ def handle_shortcut(sc_name, evt):
get_boss().send_message('goto_doc_boundary', start=False)
return True
if sc_name is 'pageup':
scroll_by_page(True)
scroll_by_page(-1)
return True
if sc_name is 'pagedown':
scroll_by_page(False)
scroll_by_page(1)
return True
return False
@ -224,9 +224,9 @@ def handle_gesture(gesture):
if not gesture.active and not gesture.is_held:
flick_animator.start(gesture)
elif gesture.type is 'prev-page':
scroll_by_page(True)
scroll_by_page(-1)
elif gesture.type is 'next-page':
scroll_by_page(False)
scroll_by_page(1)
elif gesture.type is 'long-tap':
r = word_at_point(gesture.viewport_x, gesture.viewport_y)
if r: