add a progress event in the pdfng viewer

This commit is contained in:
Brian Gough 2014-12-08 17:00:26 +00:00
parent 2a66651ec9
commit c3569dd45f
3 changed files with 12 additions and 1 deletions

View file

@ -147,6 +147,12 @@ define [
for event in attrs.resizeOn.split(",")
scope.$on event, (e) ->
#console.log 'got a resize event', event, e
#
scope.$on 'progress', (event, progress) ->
scope.$apply () ->
console.log 'progress', progress.loaded, progress.total, progress
scope.progress = Math.floor(progress.loaded/progress.total*100)
template: """
<div data-pdf-viewer class="pdfjs-viewer" pdf-src='pdfSrc' position='position' scale='scale' highlights='highlights' please-jump-to='pleaseJumpTo'></div>
@ -190,6 +196,9 @@ define [
</a>
</div>
</div>
<div class="progress-thin" ng-show="loading">
<div class="progress-bar" ng-style="{ 'width': progress + '%' }"></div>
</div>
"""
}
]

View file

@ -12,7 +12,7 @@ define [
PDFJS.disableAutoFetch = true
PDFJS.disableFontFace = true
@scale = @options.scale || 1
@document = $q.when(PDFJS.getDocument @url)
@document = $q.when(PDFJS.getDocument @url, null, null, @options.progressCallback)
@navigateFn = @options.navigateFn
@spinner = new pdfSpinner
@resetState()

View file

@ -30,6 +30,8 @@ define [
# this function captures clicks on the annotation links
$scope.navigateTo = ref
$scope.$apply()
progressCallback: (progress) ->
$scope.$emit 'progress', progress
})
# we will have all the main information needed to start display