mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #4083 from overleaf/bg-avoid-multiple-pdf-renders-on-loading
ignore pdf rendering before loading has completed GitOrigin-RevId: 3ad435507045decf49c3678abe3bfadd07d0cbca
This commit is contained in:
parent
8f0a0439cd
commit
fa914af56c
1 changed files with 8 additions and 1 deletions
|
@ -44,7 +44,9 @@ App.controller(
|
|||
// prevent race conditions)
|
||||
const documentTearDown =
|
||||
$scope.document != null ? $scope.document.destroy() : Promise.resolve()
|
||||
|
||||
// Keep track of whether the pdf has loaded (this allows rescale events to
|
||||
// be ignored until we are ready to render the pdf).
|
||||
$scope.isLoaded = false
|
||||
return documentTearDown.then(() => {
|
||||
$scope.loadCount = $scope.loadCount != null ? $scope.loadCount + 1 : 1
|
||||
// TODO need a proper url manipulation library to add to query string
|
||||
|
@ -108,6 +110,8 @@ App.controller(
|
|||
]
|
||||
// console.log 'resolved q.all, page size is', result
|
||||
$scope.$emit('loaded')
|
||||
// we can now render the document and handle rescale events
|
||||
$scope.isLoaded = true
|
||||
return ($scope.numPages = result.numPages)
|
||||
})
|
||||
.catch(function (error) {
|
||||
|
@ -399,6 +403,9 @@ export default App.directive('pdfViewer', ($q, $timeout, pdfSpinner) => ({
|
|||
let rescaleTimer = null
|
||||
const queueRescale = function (scale) {
|
||||
// console.log 'call to queueRescale'
|
||||
if (!scope.isLoaded) {
|
||||
return // ignore any requests to rescale before the document is loaded
|
||||
}
|
||||
if (rescaleTimer != null || layoutTimer != null || elementTimer != null) {
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue