E-book viewer: Fix a regression that caused the viewer to occasionally skip the last page in a chapter when displaying more than one pages per screen and scrolling by screen

Also use a custom tag name for the blank page elements, so that there is
less chance of CSS from elsewhere being applied to it
This commit is contained in:
Kovid Goyal 2015-04-20 19:12:31 +05:30
parent 60af0674f4
commit 3c74a744ef
2 changed files with 3 additions and 3 deletions

Binary file not shown.

View File

@ -33,11 +33,11 @@ has_start_text = (elem) ->
return false return false
create_page_div = (elem) -> create_page_div = (elem) ->
div = document.createElement('div') div = document.createElement('blank-page-div')
div.innerText = ' \n ' div.innerText = ' \n '
div.setAttribute('data-calibre-dummy-page', '1')
document.body.appendChild(div) document.body.appendChild(div)
div.style.setProperty('-webkit-column-break-before', 'always') div.style.setProperty('-webkit-column-break-before', 'always')
div.style.setProperty('display', 'block')
div.style.setProperty('white-space', 'pre') div.style.setProperty('white-space', 'pre')
div.style.setProperty('background-color', 'transparent') div.style.setProperty('background-color', 'transparent')
div.style.setProperty('background-image', 'none') div.style.setProperty('background-image', 'none')
@ -455,7 +455,7 @@ class PagedDisplay
if this.cols_per_screen > 1 if this.cols_per_screen > 1
width_left = document.body.scrollWidth - (window.pageXOffset + window.innerWidth) width_left = document.body.scrollWidth - (window.pageXOffset + window.innerWidth)
pages_left = width_left / this.page_width pages_left = width_left / this.page_width
if pages_left < this.cols_per_screen if Math.ceil(pages_left) < this.cols_per_screen
return -1 # Only blank, dummy pages left return -1 # Only blank, dummy pages left
limit = document.body.scrollWidth - window.innerWidth limit = document.body.scrollWidth - window.innerWidth
if ans > limit if ans > limit