mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-15 14:43:46 +01:00
use progress bar for initial loading
This commit is contained in:
@@ -82,6 +82,7 @@ define [
|
|||||||
scope.$watch "pdfSrc", (url) ->
|
scope.$watch "pdfSrc", (url) ->
|
||||||
if url
|
if url
|
||||||
scope.loading = true
|
scope.loading = true
|
||||||
|
scope.loaded = false
|
||||||
# console.log 'pdfSrc =', url
|
# console.log 'pdfSrc =', url
|
||||||
initializePosition()
|
initializePosition()
|
||||||
flashControls()
|
flashControls()
|
||||||
@@ -95,12 +96,12 @@ define [
|
|||||||
# flashControls()
|
# flashControls()
|
||||||
|
|
||||||
scope.$on "loaded", () ->
|
scope.$on "loaded", () ->
|
||||||
|
scope.loaded = true
|
||||||
scope.progress = 100
|
scope.progress = 100
|
||||||
scope.$apply()
|
|
||||||
$timeout () ->
|
$timeout () ->
|
||||||
scope.loading = false
|
scope.loading = false
|
||||||
delete scope.progress
|
delete scope.progress
|
||||||
, 250
|
, 500
|
||||||
|
|
||||||
#scope.$watch "highlights", (areas) ->
|
#scope.$watch "highlights", (areas) ->
|
||||||
# console.log 'got HIGHLIGHTS in pdfJS', areas
|
# console.log 'got HIGHLIGHTS in pdfJS', areas
|
||||||
@@ -163,6 +164,7 @@ define [
|
|||||||
|
|
||||||
scope.$on 'progress', (event, progress) ->
|
scope.$on 'progress', (event, progress) ->
|
||||||
scope.$apply () ->
|
scope.$apply () ->
|
||||||
|
return if scope.loaded
|
||||||
scope.progress = Math.floor(progress.loaded/progress.total*100)
|
scope.progress = Math.floor(progress.loaded/progress.total*100)
|
||||||
scope.progress = 100 if scope.progress > 100
|
scope.progress = 100 if scope.progress > 100
|
||||||
scope.progress = 0 if scope.progress < 0
|
scope.progress = 0 if scope.progress < 0
|
||||||
|
|||||||
@@ -41,7 +41,6 @@ define [
|
|||||||
$scope.navigateTo = ref
|
$scope.navigateTo = ref
|
||||||
$scope.$apply()
|
$scope.$apply()
|
||||||
progressCallback: (progress) ->
|
progressCallback: (progress) ->
|
||||||
return if onDemandLoading is true # don't show progress for on-demand page loading
|
|
||||||
$scope.$emit 'progress', progress
|
$scope.$emit 'progress', progress
|
||||||
loadedCallback: () ->
|
loadedCallback: () ->
|
||||||
$scope.$emit 'loaded'
|
$scope.$emit 'loaded'
|
||||||
@@ -65,6 +64,7 @@ define [
|
|||||||
result.pdfViewport.width
|
result.pdfViewport.width
|
||||||
]
|
]
|
||||||
# console.log 'resolved q.all, page size is', result
|
# console.log 'resolved q.all, page size is', result
|
||||||
|
$scope.$emit 'loaded'
|
||||||
$scope.numPages = result.numPages
|
$scope.numPages = result.numPages
|
||||||
.catch (error) ->
|
.catch (error) ->
|
||||||
$scope.$emit 'pdf:error', error
|
$scope.$emit 'pdf:error', error
|
||||||
|
|||||||
Reference in New Issue
Block a user