Finish up zone tap gestures

This commit is contained in:
Kovid Goyal 2016-08-22 15:01:04 +05:30
parent 5fc6b6db39
commit 1df8918fdd
3 changed files with 16 additions and 8 deletions

View File

@ -62,9 +62,9 @@ def goto_boundary(y):
window.scrollTo(window.pageXOffset, 0)
@check_for_scroll_end
def scroll_by_page(y):
def scroll_by_page(backward):
h = window.innerHeight - 10
window.scrollBy(0, -h if y < 0 else h)
window.scrollBy(0, -h if backward else h)
def flow_onkeydown(evt):
handled = False
@ -92,7 +92,7 @@ def flow_onkeydown(evt):
window.scrollTo(window.pageXOffset, document_height())
elif key is 'pageup' or key is 'pagedown' or key is 'space':
handled = True
scroll_by_page(-1 if key is 'pageup' else 1)
scroll_by_page(key is 'pageup')
if handled:
evt.preventDefault()
@ -158,3 +158,7 @@ def handle_gesture(gesture):
window.scrollBy(delta, 0)
if not gesture.active and not gesture.is_held:
flick_animator.start(gesture)
elif gesture.type is 'prev-page':
scroll_by_page(True)
elif gesture.type is 'next-page':
scroll_by_page(False)

View File

@ -500,3 +500,7 @@ def handle_gesture(gesture):
else:
if not gesture.active or gesture.is_held:
scroll_by_page(gesture.direction is 'right', True)
elif gesture.type is 'prev-page':
scroll_by_page(True, False)
elif gesture.type is 'next-page':
scroll_by_page(False, False)

View File

@ -204,13 +204,13 @@ class TouchHandler:
elem.dispatchEvent(fake_click)
return
if not tap_on_link(gesture):
if gesture.viewport_y < window.innerHeight / 4:
if gesture.viewport_y < min(100, window.innerHeight / 4):
gesture.type = 'show-chrome'
else:
# TODO: Convert the tap gesture into
# semantic gestures based on position of tap (next page/previous
# page/show ui) as these are common to both paged and flow mode.
pass
if gesture.viewport_x < min(100, window.innerWidth / 4):
gesture.type = 'prev-page'
else:
gesture.type = 'next-page'
get_boss().handle_gesture(gesture)
touch_handler = TouchHandler()