mirror of
https://github.com/pdf2htmlEX/pdf2htmlEX.git
synced 2024-10-05 19:41:40 +00:00
pdf2htmlEX.js: reveal prev and next page for a better reading experience
This commit is contained in:
parent
11f3bb715e
commit
83b25c091b
@ -84,10 +84,19 @@ var pdf2htmlEX = (function(){
|
|||||||
this.p.height(this.b.height() * this.set_r);
|
this.p.height(this.b.height() * this.set_r);
|
||||||
this.p.width(this.b.width() * 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() {
|
is_visible : function() {
|
||||||
var off = this.position();
|
var off = this.position();
|
||||||
return !((off[1] > this.height()) || (off[1] + this.container.height() < 0));
|
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
|
/* return the coordinate of the top-left corner of container
|
||||||
* in our cooridnate system
|
* in our cooridnate system
|
||||||
*/
|
*/
|
||||||
@ -199,7 +208,7 @@ var pdf2htmlEX = (function(){
|
|||||||
var pl = this.pages;
|
var pl = this.pages;
|
||||||
for(var i in pl) {
|
for(var i in pl) {
|
||||||
var p = pl[i];
|
var p = pl[i];
|
||||||
if(p.is_visible()){
|
if(p.is_nearly_visible()){
|
||||||
p.show();
|
p.show();
|
||||||
} else {
|
} else {
|
||||||
p.hide();
|
p.hide();
|
||||||
|
Loading…
Reference in New Issue
Block a user