Tapping in the top quarter of the page now shows the chrome

This commit is contained in:
Kovid Goyal 2016-08-22 14:50:23 +05:30
parent 5eaccd6619
commit 5fc6b6db39
3 changed files with 20 additions and 7 deletions

View File

@ -94,7 +94,7 @@ class IframeBoss:
self.do_layout = flow_layout
self.handle_wheel = flow_onwheel
self.handle_keydown = flow_onkeydown
self.handle_gesture = flow_handle_gesture
self._handle_gesture = flow_handle_gesture
self.to_scroll_fraction = flow_to_scroll_fraction
self.jump_to_cfi = scroll_to_cfi
else:
@ -103,13 +103,19 @@ class IframeBoss:
self.handle_keydown = paged_onkeydown
self.to_scroll_fraction = paged_scroll_to_fraction
self.jump_to_cfi = paged_jump_to_cfi
self.handle_gesture = paged_handle_gesture
self._handle_gesture = paged_handle_gesture
apply_settings(data.settings)
set_current_spine_item({'name':data.name, 'is_first':index is 0, 'is_last':index is spine.length - 1, 'initial_position':data.initial_position})
self.last_cfi = None
root_data, self.mathjax = finalize_resources(self.book, data.name, data.resource_data)
unserialize_html(root_data, self.content_loaded)
def handle_gesture(self, gesture):
if gesture.type is 'show-chrome':
self.send_message('show_chrome')
else:
self._handle_gesture(gesture)
def on_scroll_to_anchor(self, data):
frag = data.frag
if frag:

View File

@ -204,6 +204,9 @@ class TouchHandler:
elem.dispatchEvent(fake_click)
return
if not tap_on_link(gesture):
if gesture.viewport_y < 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.

View File

@ -66,6 +66,7 @@ class View:
'scroll_to_anchor': self.on_scroll_to_anchor,
'update_cfi': self.on_update_cfi,
'content_loaded': self.on_content_loaded,
'show_chrome': self.show_chrome,
}
self.currently_showing = {}
document.getElementById('book-top-margin').addEventListener('click', self.top_margin_clicked)
@ -77,6 +78,9 @@ class View:
def top_margin_clicked(self, event):
if event.button is 0:
event.preventDefault(), event.stopPropagation()
self.show_chrome()
def show_chrome(self):
self.overlay.show()
def set_margins(self, no_margins):