mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-05-09 03:45:22 +02:00
E-book viewer: Fix incorrect toc navigation in books that link the entries to inline tags that wrap block tags that span multiple pages. Fixes #1918437 [Book reader incorrectly go to table of contents items](https://bugs.launchpad.net/calibre/+bug/1918437)
This commit is contained in:
parent
7b77ab672b
commit
537efd11b1
1 changed files with 13 additions and 0 deletions
|
|
@ -506,7 +506,19 @@ def jump_to_anchor(name):
|
|||
scroll_to_elem(elem)
|
||||
|
||||
|
||||
def scrollable_element(elem):
|
||||
# bounding rect calculation for an inline element containing a block
|
||||
# element that spans multiple columns is incorrect. Detet the common case
|
||||
# of this and avoid it.
|
||||
if not in_paged_mode() or window.getComputedStyle(elem).display.indexOf('inline') < 0 or not elem.firstElementChild:
|
||||
return elem
|
||||
if window.getComputedStyle(elem.firstElementChild).display.indexOf('block') > -1:
|
||||
return elem.firstElementChild
|
||||
return elem
|
||||
|
||||
|
||||
def scroll_to_elem(elem):
|
||||
elem = scrollable_element(elem)
|
||||
scroll_viewport.scroll_into_view(elem)
|
||||
|
||||
if in_paged_mode():
|
||||
|
|
@ -786,6 +798,7 @@ def handle_gesture(gesture):
|
|||
'pos_for_elem': def pos_for_elem(elem):
|
||||
if not elem:
|
||||
return 0
|
||||
elem = scrollable_element(elem)
|
||||
br = elem.getBoundingClientRect()
|
||||
pos = scroll_viewport.viewport_to_document_inline(
|
||||
scroll_viewport.rect_inline_start(br))
|
||||
|
|
|
|||
Loading…
Reference in a new issue