From 83b25c091bed90accd233ca95bf880689c352348 Mon Sep 17 00:00:00 2001 From: Lu Wang Date: Thu, 2 May 2013 16:45:00 +0800 Subject: [PATCH] pdf2htmlEX.js: reveal prev and next page for a better reading experience --- share/pdf2htmlEX.js.in | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/share/pdf2htmlEX.js.in b/share/pdf2htmlEX.js.in index 9069eb1..6c1a432 100644 --- a/share/pdf2htmlEX.js.in +++ b/share/pdf2htmlEX.js.in @@ -84,10 +84,19 @@ var pdf2htmlEX = (function(){ this.p.height(this.b.height() * this.set_r); this.p.width(this.b.width() * this.set_r); }, + /* return if any part of this page is shown in the container */ is_visible : function() { var off = this.position(); return !((off[1] > this.height()) || (off[1] + this.container.height() < 0)); }, + /* return if this page or any neighbor of it is visible */ + is_nearly_visible : function() { + var off = this.position(); + /* I should use the height of the previous page or the next page here + * but since they are not easily available, just use '*2', which should be a good estimate in most cases + */ + return !((off[1] > this.height() * 2) || (off[1] + this.container.height() * 2 < 0)); + }, /* return the coordinate of the top-left corner of container * in our cooridnate system */ @@ -199,7 +208,7 @@ var pdf2htmlEX = (function(){ var pl = this.pages; for(var i in pl) { var p = pl[i]; - if(p.is_visible()){ + if(p.is_nearly_visible()){ p.show(); } else { p.hide();