1
0
mirror of https://github.com/pdf2htmlEX/pdf2htmlEX.git synced 2024-07-05 01:28:39 +00:00

pdf2htmlEX.js: reveal prev and next page for a better reading experience

This commit is contained in:
Lu Wang 2013-05-02 16:45:00 +08:00
parent 11f3bb715e
commit 83b25c091b

View File

@ -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();