mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Navigate to CFIs correctly in paged mode and fix typo in current_column_location()
This commit is contained in:
parent
957bd0512f
commit
fc4309539b
Binary file not shown.
@ -161,7 +161,7 @@ class PagedDisplay
|
|||||||
# The location of the left edge of the left most column currently
|
# The location of the left edge of the left most column currently
|
||||||
# visible in the viewport
|
# visible in the viewport
|
||||||
x = window.pageXOffset + Math.max(10, this.current_margin_side)
|
x = window.pageXOffset + Math.max(10, this.current_margin_side)
|
||||||
edge = Math.floor(x/this.page_width)
|
edge = Math.floor(x/this.page_width) * this.page_width
|
||||||
while edge < x
|
while edge < x
|
||||||
edge += this.page_width
|
edge += this.page_width
|
||||||
return edge - this.page_width
|
return edge - this.page_width
|
||||||
@ -237,6 +237,18 @@ class PagedDisplay
|
|||||||
# selection
|
# selection
|
||||||
this.scroll_to_xpos(left+5)
|
this.scroll_to_xpos(left+5)
|
||||||
|
|
||||||
|
jump_to_cfi: (cfi) ->
|
||||||
|
# Jump to the position indicated by the specified conformal fragment
|
||||||
|
# indicator (requires the cfi.coffee library). When in paged mode, the
|
||||||
|
# scroll is performed so that the column containing the position
|
||||||
|
# pointed to by the cfi is the left most column in the viewport
|
||||||
|
window.cfi.scroll_to(cfi, (x, y) =>
|
||||||
|
if this.in_paged_mode
|
||||||
|
this.scroll_to_xpos(x)
|
||||||
|
else
|
||||||
|
window.scrollTo(0, y)
|
||||||
|
)
|
||||||
|
|
||||||
if window?
|
if window?
|
||||||
window.paged_display = new PagedDisplay()
|
window.paged_display = new PagedDisplay()
|
||||||
|
|
||||||
|
@ -37,17 +37,8 @@ class PagePosition(object):
|
|||||||
def scroll_to_cfi(self, cfi):
|
def scroll_to_cfi(self, cfi):
|
||||||
if cfi:
|
if cfi:
|
||||||
cfi = json.dumps(cfi)
|
cfi = json.dumps(cfi)
|
||||||
self.document.mainFrame().evaluateJavaScript('''
|
self.document.mainFrame().evaluateJavaScript(
|
||||||
function fix_scroll() {
|
'paged_display.jump_to_cfi(%s)'%cfi)
|
||||||
/* cfi.scroll_to() uses scrollIntoView() which can result
|
|
||||||
in scrolling along the x-axis. So we
|
|
||||||
explicitly scroll to x=0.
|
|
||||||
*/
|
|
||||||
scrollTo(0, window.pageYOffset)
|
|
||||||
}
|
|
||||||
|
|
||||||
window.cfi.scroll_to(%s, fix_scroll);
|
|
||||||
'''%cfi)
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def current_pos(self):
|
def current_pos(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user