1
0
mirror of https://github.com/pdf2htmlEX/pdf2htmlEX.git synced 2024-12-22 13:00:08 +00:00

improve scroll.js

This commit is contained in:
Lu Wang 2012-09-18 15:27:17 +08:00
parent 866866f9d0
commit d63ef17538
3 changed files with 22 additions and 17 deletions

View File

@ -24,7 +24,7 @@
@base.css
$css
@jquery.js
#@hide_pages.js
@hide_pages.js
"""
<title></title>
@ -39,7 +39,7 @@ $pages
</div>
"""
#@scroll.js
@scroll.js
"""
</body>

View File

@ -1,3 +1,10 @@
/*
* scroll.js
* render only necessary pages
*
* by Hongliang TIAN
* modifiedy by Lu WANG
*/
$(function() {
var $pages = $(".p"),
$pageWrappers = $(".b"),
@ -37,23 +44,22 @@ $(function() {
}
// Listen to scrolling events to render proper pages
var scrollTimer = null;
var scrolled = false;
var last_scroll_time = Date.now();
$("#pdf-main").scroll(function() {
// Now
lastScrollTime = Date.now();
// Make sure at most one timer runs
clearInterval(scrollTimer);
// Check when scrolling stops
scrollTimer = setInterval(function() {
// If scrolling pauses 200+ms
if (Date.now() - lastScrollTime > 200) {
clearInterval(scrollTimer);
// Only render pages that are or will be visible
selectiveRender();
}
}, 200);
scrolled = true;
last_scroll_time = Date.now();
});
setInterval(function() {
// If scrolling pauses 200+ms
if (scrolled && (Date.now() - last_scroll_time> 100)) {
scrolled = false;
// Only render pages that are or will be visible
selectiveRender();
}
}, 100);
// Trigger the event
$("#pdf-main").scroll();
});

View File

@ -56,7 +56,6 @@ HTMLRenderer::~HTMLRenderer()
}
static GBool annot_cb(Annot *, void *) {
return true;
return false;
};