1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-20 23:28:06 +02:00

Require destinations when they are needed and do not fetch all of them in advance

This commit is contained in:
Tim van der Meij 2014-10-05 15:56:40 +02:00
parent fb6d87c77b
commit b215af30d3
5 changed files with 80 additions and 16 deletions

View file

@ -675,15 +675,19 @@ var PDFViewerApplication = {
}
};
this.destinationsPromise.then(function() {
if (typeof dest === 'string') {
destString = dest;
dest = self.destinations[dest];
}
if (!(dest instanceof Array)) {
var destinationPromise;
if (typeof dest === 'string') {
destString = dest;
destinationPromise = this.pdfDocument.getDestination(dest);
} else {
destinationPromise = Promise.resolve(dest);
}
destinationPromise.then(function(destination) {
dest = destination;
if (!(destination instanceof Array)) {
return; // invalid destination
}
goToDestination(dest[0]);
goToDestination(destination[0]);
});
},
@ -984,15 +988,8 @@ var PDFViewerApplication = {
}
});
var destinationsPromise =
this.destinationsPromise = pdfDocument.getDestinations();
destinationsPromise.then(function(destinations) {
self.destinations = destinations;
});
// outline depends on destinations and pagesRefMap
var promises = [pagesPromise, destinationsPromise,
this.animationStartedPromise];
// outline depends on pagesRefMap
var promises = [pagesPromise, this.animationStartedPromise];
Promise.all(promises).then(function() {
pdfDocument.getOutline().then(function(outline) {
var outlineView = document.getElementById('outlineView');