loading the max 15 thumbnails first time
This commit is contained in:
parent
29d0d8a8a9
commit
32f681cfcf
@ -274,6 +274,12 @@ var PDFViewer = {
|
||||
openURL: function(url) {
|
||||
PDFViewer.url = url;
|
||||
document.title = url;
|
||||
|
||||
if (this.thumbsLoadingInterval) {
|
||||
// cancel thumbs loading operations
|
||||
clearInterval(this.thumbsLoadingInterval);
|
||||
this.thumbsLoadingInterval = null;
|
||||
}
|
||||
|
||||
var req = new XMLHttpRequest();
|
||||
req.open('GET', url);
|
||||
@ -290,7 +296,9 @@ var PDFViewer = {
|
||||
|
||||
req.send(null);
|
||||
},
|
||||
|
||||
|
||||
thumbsLoadingInterval: null,
|
||||
|
||||
readPDF: function(data) {
|
||||
while (PDFViewer.element.hasChildNodes()) {
|
||||
PDFViewer.element.removeChild(PDFViewer.element.firstChild);
|
||||
@ -312,12 +320,22 @@ var PDFViewer = {
|
||||
PDFViewer.drawPage(1);
|
||||
document.location.hash = 1;
|
||||
|
||||
setTimeout(function() {
|
||||
for (var i = 1; i <= PDFViewer.numberOfPages; i++) {
|
||||
PDFViewer.createThumbnail(i);
|
||||
PDFViewer.drawThumbnail(i);
|
||||
// slowly loading the thumbs (few per second)
|
||||
// first time we are loading more images than subsequent
|
||||
var currentPageIndex = 1, imagesToLoad = 15;
|
||||
this.thumbsLoadingInterval = setInterval((function() {
|
||||
while (imagesToLoad-- > 0) {
|
||||
if (currentPageIndex > PDFViewer.numberOfPages) {
|
||||
clearInterval(this.thumbsLoadingInterval);
|
||||
this.thumbsLoadingInterval = null;
|
||||
return;
|
||||
}
|
||||
PDFViewer.createThumbnail(currentPageIndex);
|
||||
PDFViewer.drawThumbnail(currentPageIndex);
|
||||
++currentPageIndex;
|
||||
}
|
||||
}, 500);
|
||||
imagesToLoad = 3; // next time loading less images
|
||||
}).bind(this), 500);
|
||||
}
|
||||
|
||||
PDFViewer.previousPageButton.className = (PDFViewer.pageNumber === 1) ? 'disabled' : '';
|
||||
|
Loading…
Reference in New Issue
Block a user