diff options
author | Mike Greiling <mike@pixelcog.com> | 2019-07-29 20:18:53 +0300 |
---|---|---|
committer | Mike Greiling <mike@pixelcog.com> | 2019-07-29 20:18:53 +0300 |
commit | f039d592aa6203502be487801777167e433ad9d2 (patch) | |
tree | a774fc0096e21d6cb8e576bdce4fd2451c17d7ff | |
parent | 0715febb574d2126719bc3ab738a8749dda12b13 (diff) | |
parent | 5246626d2cf8bb23e4fb9a7172542573a6e17ba3 (diff) |
Merge branch 'sh-fix-pdfjs-page-ordering' into 'master'
Fix pdf.js rendering pages in the wrong order
Closes #64467
See merge request gitlab-org/gitlab-ce!31222
-rw-r--r-- | app/assets/javascripts/pdf/index.vue | 16 | ||||
-rw-r--r-- | app/assets/javascripts/pdf/page/index.vue | 4 | ||||
-rw-r--r-- | changelogs/unreleased/sh-fix-pdfjs-page-ordering.yml | 5 |
3 files changed, 16 insertions, 9 deletions
diff --git a/app/assets/javascripts/pdf/index.vue b/app/assets/javascripts/pdf/index.vue index 6d39abd4a1f..2b468aa5744 100644 --- a/app/assets/javascripts/pdf/index.vue +++ b/app/assets/javascripts/pdf/index.vue @@ -14,7 +14,6 @@ export default { }, data() { return { - loading: false, pages: [], }; }, @@ -37,17 +36,18 @@ export default { return pdfjsLib .getDocument(this.document) .then(this.renderPages) - .then(() => this.$emit('pdflabload')) - .catch(error => this.$emit('pdflaberror', error)) - .then(() => { - this.loading = false; + .then(pages => { + this.pages = pages; + this.$emit('pdflabload'); + }) + .catch(error => { + this.$emit('pdflaberror', error); }); }, renderPages(pdf) { const pagePromises = []; - this.loading = true; for (let num = 1; num <= pdf.numPages; num += 1) { - pagePromises.push(pdf.getPage(num).then(p => this.pages.push(p))); + pagePromises.push(pdf.getPage(num)); } return Promise.all(pagePromises); }, @@ -59,8 +59,8 @@ export default { <div v-if="hasPDF" class="pdf-viewer"> <page v-for="(page, index) in pages" + v-if="page" :key="index" - :v-if="!loading" :page="page" :number="index + 1" /> diff --git a/app/assets/javascripts/pdf/page/index.vue b/app/assets/javascripts/pdf/page/index.vue index f16aaca6cd7..d933fdf220a 100644 --- a/app/assets/javascripts/pdf/page/index.vue +++ b/app/assets/javascripts/pdf/page/index.vue @@ -39,7 +39,9 @@ export default { .then(() => { this.rendering = false; }) - .catch(error => this.$emit('pdflaberror', error)); + .catch(error => { + this.$emit('pdflaberror', error); + }); }, }; </script> diff --git a/changelogs/unreleased/sh-fix-pdfjs-page-ordering.yml b/changelogs/unreleased/sh-fix-pdfjs-page-ordering.yml new file mode 100644 index 00000000000..84161c51905 --- /dev/null +++ b/changelogs/unreleased/sh-fix-pdfjs-page-ordering.yml @@ -0,0 +1,5 @@ +--- +title: Fix pdf.js rendering pages in the wrong order +merge_request: 31222 +author: +type: fixed |