add loadedCallback to pdfng, detects when pdf is fully loaded

This commit is contained in:
Brian Gough 2015-01-13 16:28:24 +00:00
parent 953821959d
commit 5e06043fcb
2 changed files with 5 additions and 1 deletions

View file

@ -19,6 +19,9 @@ define [
@navigateFn = @options.navigateFn @navigateFn = @options.navigateFn
@spinner = new pdfSpinner @spinner = new pdfSpinner
@resetState() @resetState()
@document.then (pdfDocument) =>
pdfDocument.getDownloadInfo().then () =>
@options.loadedCallback()
resetState: () -> resetState: () ->
@page = [] @page = []

View file

@ -35,6 +35,8 @@ define [
$scope.$apply() $scope.$apply()
progressCallback: (progress) -> progressCallback: (progress) ->
$scope.$emit 'progress', progress $scope.$emit 'progress', progress
loadedCallback: () ->
$scope.$emit 'loaded'
}) })
# we will have all the main information needed to start display # we will have all the main information needed to start display
@ -51,7 +53,6 @@ define [
] ]
# console.log 'resolved q.all, page size is', result # console.log 'resolved q.all, page size is', result
$scope.numPages = result.numPages $scope.numPages = result.numPages
$scope.$emit "loaded"
@setScale = (scale, containerHeight, containerWidth) -> @setScale = (scale, containerHeight, containerWidth) ->
$scope.loaded.then () -> $scope.loaded.then () ->