mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
defer loading of pdf destinations until required
This commit is contained in:
parent
1e2e1ecb9c
commit
b157323eb7
2 changed files with 16 additions and 7 deletions
|
@ -47,6 +47,19 @@ define [
|
|||
@document.then (pdfDocument) ->
|
||||
pdfDocument.getDestinations()
|
||||
|
||||
# Not available in pdf.js-1.0.712, in later versions there is a direct
|
||||
# call for this - we should use it as soon as it is available in a
|
||||
# stable version
|
||||
getDestination: (dest) ->
|
||||
@destinations = @document.then (pdfDocument) ->
|
||||
pdfDocument.getDestinations()
|
||||
return @destinations.then (all) ->
|
||||
all[dest]
|
||||
|
||||
@document.then (pdfDocument) ->
|
||||
pdfDocument.getDestination(dest)
|
||||
|
||||
|
||||
getPageIndex: (ref) ->
|
||||
@document.then (pdfDocument) ->
|
||||
pdfDocument.getPageIndex(ref).then (idx) ->
|
||||
|
|
|
@ -38,7 +38,6 @@ define [
|
|||
# after the following promise is resolved
|
||||
$scope.loaded = $q.all({
|
||||
numPages: $scope.document.getNumPages()
|
||||
destinations: $scope.document.getDestinations()
|
||||
# get size of first page as default @ scale 1
|
||||
pdfViewport: $scope.document.getPdfViewport 1, 1
|
||||
}).then (result) ->
|
||||
|
@ -47,7 +46,6 @@ define [
|
|||
result.pdfViewport.height,
|
||||
result.pdfViewport.width
|
||||
]
|
||||
$scope.destinations = result.destinations
|
||||
# console.log 'resolved q.all, page size is', result
|
||||
$scope.numPages = result.numPages
|
||||
$scope.$emit "loaded"
|
||||
|
@ -365,11 +363,9 @@ define [
|
|||
scope.navigateTo = undefined
|
||||
# console.log 'navigate to', newVal
|
||||
# console.log 'look up page num'
|
||||
scope.loaded.then () ->
|
||||
# console.log 'destinations are', scope.destinations
|
||||
r = scope.destinations[newVal.dest]
|
||||
# console.log 'need to go to', r
|
||||
# console.log 'page ref is', r[0]
|
||||
scope.document.getDestination(newVal.dest).then (r) ->
|
||||
console.log 'need to go to', r
|
||||
console.log 'page ref is', r[0]
|
||||
scope.document.getPageIndex(r[0]).then (pidx) ->
|
||||
# console.log 'page num is', pidx
|
||||
page = scope.pages[pidx]
|
||||
|
|
Loading…
Reference in a new issue