From eaca616dd37aa7b8a211ef64a84171fa5ea2c7f9 Mon Sep 17 00:00:00 2001 From: Brian Gough Date: Fri, 1 Jul 2016 17:00:06 +0100 Subject: [PATCH] use progress bar for initial loading --- .../web/public/coffee/ide/pdfng/directives/pdfJs.coffee | 6 ++++-- .../web/public/coffee/ide/pdfng/directives/pdfViewer.coffee | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/services/web/public/coffee/ide/pdfng/directives/pdfJs.coffee b/services/web/public/coffee/ide/pdfng/directives/pdfJs.coffee index 310a9ba7f8..65e6b3d88c 100644 --- a/services/web/public/coffee/ide/pdfng/directives/pdfJs.coffee +++ b/services/web/public/coffee/ide/pdfng/directives/pdfJs.coffee @@ -82,6 +82,7 @@ define [ scope.$watch "pdfSrc", (url) -> if url scope.loading = true + scope.loaded = false # console.log 'pdfSrc =', url initializePosition() flashControls() @@ -95,12 +96,12 @@ define [ # flashControls() scope.$on "loaded", () -> + scope.loaded = true scope.progress = 100 - scope.$apply() $timeout () -> scope.loading = false delete scope.progress - , 250 + , 500 #scope.$watch "highlights", (areas) -> # console.log 'got HIGHLIGHTS in pdfJS', areas @@ -163,6 +164,7 @@ define [ scope.$on 'progress', (event, progress) -> scope.$apply () -> + return if scope.loaded scope.progress = Math.floor(progress.loaded/progress.total*100) scope.progress = 100 if scope.progress > 100 scope.progress = 0 if scope.progress < 0 diff --git a/services/web/public/coffee/ide/pdfng/directives/pdfViewer.coffee b/services/web/public/coffee/ide/pdfng/directives/pdfViewer.coffee index 6b6aaff2d5..926eea880c 100644 --- a/services/web/public/coffee/ide/pdfng/directives/pdfViewer.coffee +++ b/services/web/public/coffee/ide/pdfng/directives/pdfViewer.coffee @@ -41,7 +41,6 @@ define [ $scope.navigateTo = ref $scope.$apply() progressCallback: (progress) -> - return if onDemandLoading is true # don't show progress for on-demand page loading $scope.$emit 'progress', progress loadedCallback: () -> $scope.$emit 'loaded' @@ -65,6 +64,7 @@ define [ result.pdfViewport.width ] # console.log 'resolved q.all, page size is', result + $scope.$emit 'loaded' $scope.numPages = result.numPages .catch (error) -> $scope.$emit 'pdf:error', error