mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix incorrect scroll direction detection in flow mode
This commit is contained in:
parent
9dd8170596
commit
a8eca0d6d2
@ -13,7 +13,7 @@ def check_for_scroll_end(func):
|
|||||||
before = window.pageYOffset
|
before = window.pageYOffset
|
||||||
func.apply(this, arguments)
|
func.apply(this, arguments)
|
||||||
if window.pageYOffset is before:
|
if window.pageYOffset is before:
|
||||||
get_boss().send_message('next_spine_item', previous=window.pageYOffset < 5)
|
get_boss().send_message('next_spine_item', previous=arguments[0] < 0)
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@ -56,17 +56,13 @@ def smooth_y_scroll(up):
|
|||||||
do_y_scroll()
|
do_y_scroll()
|
||||||
|
|
||||||
@check_for_scroll_end
|
@check_for_scroll_end
|
||||||
def goto_start():
|
def goto_boundary(y):
|
||||||
window.scrollTo(window.pageXOffset, 0)
|
window.scrollTo(window.pageXOffset, 0)
|
||||||
|
|
||||||
@check_for_scroll_end
|
@check_for_scroll_end
|
||||||
def goto_end():
|
def scroll_by_page(y):
|
||||||
window.scrollTo(window.pageXOffset, document_height())
|
|
||||||
|
|
||||||
@check_for_scroll_end
|
|
||||||
def scroll_by_page(up):
|
|
||||||
h = window.innerHeight - 10
|
h = window.innerHeight - 10
|
||||||
window.scrollBy(0, -h if up else h)
|
window.scrollBy(0, -h if y < 0 else h)
|
||||||
|
|
||||||
def flow_onkeydown(evt):
|
def flow_onkeydown(evt):
|
||||||
handled = False
|
handled = False
|
||||||
@ -74,7 +70,7 @@ def flow_onkeydown(evt):
|
|||||||
if key is 'up' or key is 'down':
|
if key is 'up' or key is 'down':
|
||||||
handled = True
|
handled = True
|
||||||
if evt.ctrlKey:
|
if evt.ctrlKey:
|
||||||
goto_start() if key is 'up' else goto_end()
|
goto_boundary(-1 if key is 'up' else 1)
|
||||||
else:
|
else:
|
||||||
smooth_y_scroll(key is 'up')
|
smooth_y_scroll(key is 'up')
|
||||||
elif key is 'left' or key is 'right':
|
elif key is 'left' or key is 'right':
|
||||||
@ -94,6 +90,6 @@ def flow_onkeydown(evt):
|
|||||||
window.scrollTo(window.pageXOffset, document_height())
|
window.scrollTo(window.pageXOffset, document_height())
|
||||||
elif key is 'pageup' or key is 'pagedown' or key is 'space':
|
elif key is 'pageup' or key is 'pagedown' or key is 'space':
|
||||||
handled = True
|
handled = True
|
||||||
scroll_by_page(key is 'pageup')
|
scroll_by_page(-1 if key is 'pageup' else 1)
|
||||||
if handled:
|
if handled:
|
||||||
evt.preventDefault()
|
evt.preventDefault()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user