From 76f15827572d0ddeaffe4e78d353bf014f4cf946 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 13 Apr 2015 14:09:59 +0530 Subject: [PATCH] E-book viewer: When displaying multiple pages per screen fix whole screen scrolling so that it works as expected even at the end of the file, when their might be fewer pages left than would fill the screen. --- resources/compiled_coffeescript.zip | Bin 102835 -> 103952 bytes src/calibre/ebooks/oeb/display/paged.coffee | 23 ++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/resources/compiled_coffeescript.zip b/resources/compiled_coffeescript.zip index 9524eb8797154eac87eb0ccd029d13fef25e330a..c0b8d2e5b1bda00269aac2123a94ad24a25ad85f 100644 GIT binary patch delta 1009 zcmZuwO-vI(6y~*9n+oz{jYU9*n$Q+$-BO?p2ni;lCVC){5Tm4ScV}U--L1P@t09DV z(`bKi593*h2V#uUL_J}=sgZ+;7f!^RH}z)XL1((vk_~&Ad2hb&+xNaVQ+eVlKXbkK zuyL^cMqzSfb8T#Wv7upok<4{KhxudUUW=e%-oVK$KaZ25e6y0TY&Y7I1g4>DA3YuQ znA=Cge!7duih{Kne9J&%D1fdih<<@l4_oLl`MeC?PJvI$DGi6kTqbin%zhE*M}cS{ zM0KuwJ=RQtbX%jCQ$Hu1G(%T!cYZ-Oa9GdsLY0!$FeBBG-o6wsT%Xs}oFaw=HLYq) z+0b}}ax|U0WNLA|}mSdjGy zZAedMvGy-Nj-ny7RBfMGfDo0Tw(p4zqo`$+g``HNF$yxmIO6`R05V&%UY~_Q$aV>W z1kQlZ+*xa>T>SKY*w>HP?DS+BOGZDcdQ;t#2m4`#m`>;%VBPFlkFEAP+3aaLLY}+8 z4M8&DhC}g_R9O+#ymhr^*#v4cXJytapq;geO%LZ{Y@7a?jZtL!doISa+i!3%?(5(~HE8;hiHwoVu9A$?FHQie zJ207%W4g>FMlGg!I@2dk0*b^;Vl-xAHUn|InSS{}1V2q;lw#W2J)LhdqvZ64iHuy+ zH%(!*p1xoTBL~ny96Cx?3Q8$y=H|(!#%AV;X~~I(mdPpR76yq%siuY&My4i4sX&&g zMT(($+VqK27{#YMOl9<(e72u^dMe1Ew^JCsK?M8s3091})5W1;?9+=UGx|>NoXQwD TIX97Oy5VG~r66~kGS&hBOFeDJ diff --git a/src/calibre/ebooks/oeb/display/paged.coffee b/src/calibre/ebooks/oeb/display/paged.coffee index c6b762b519..b9509d6dfd 100644 --- a/src/calibre/ebooks/oeb/display/paged.coffee +++ b/src/calibre/ebooks/oeb/display/paged.coffee @@ -32,6 +32,19 @@ has_start_text = (elem) -> return true return false +create_page_div = (elem) -> + div = document.createElement('div') + div.innerText = ' \n ' + div.setAttribute('data-calibre-dummy-page', '1') + document.body.appendChild(div) + div.style.setProperty('-webkit-column-break-before', 'always') + div.style.setProperty('white-space', 'pre') + div.style.setProperty('background-color', 'transparent') + div.style.setProperty('background-image', 'none') + div.style.setProperty('border-width', '0') + div.style.setProperty('float', 'none') + div.style.setProperty('position', 'static') + class PagedDisplay # This class is a namespace to expose functions via the # window.paged_display object. The most important functions are: @@ -125,6 +138,11 @@ class PagedDisplay single_screen = (document.body.scrollHeight < window.innerHeight + 75) this.handle_rtl_body(body_style) first_layout = true + if not single_screen and this.cols_per_screen > 1 + num = this.cols_per_screen - 1 + while num > 0 + num -= 1 + create_page_div() ww = window.innerWidth @@ -434,6 +452,11 @@ class PagedDisplay return -1 cc = this.current_column_location() ans = cc + this.screen_width + if this.cols_per_screen > 1 + width_left = document.body.scrollWidth - (window.pageXOffset + window.innerWidth) + pages_left = width_left / this.page_width + if pages_left < this.cols_per_screen + return -1 # Only blank, dummy pages left limit = document.body.scrollWidth - window.innerWidth if ans > limit ans = if window.pageXOffset < limit then limit else -1