check initVuePdfEmbed before intersectionobserver API
This commit is contained in:
parent
28865658d2
commit
6cb4984e46
1 changed files with 7 additions and 5 deletions
|
|
@ -153,11 +153,14 @@ const { doc } = useVuePdfEmbed({
|
|||
source: pdfSource,
|
||||
});
|
||||
|
||||
const initVuePdfEmbed = computed(()=> props.showInlinePDF && isPDF.value)
|
||||
|
||||
const pageNums = computed(() =>
|
||||
doc.value ? [...Array(doc.value.numPages + 1).keys()].slice(1) : []
|
||||
);
|
||||
|
||||
const resetPageIntersectionObserver = () => {
|
||||
if(!initVuePdfEmbed.value) return
|
||||
pageIntersectionObserver?.disconnect()
|
||||
pageIntersectionObserver = new IntersectionObserver((entries) => {
|
||||
entries.forEach((entry) => {
|
||||
|
|
@ -177,17 +180,16 @@ const resetPageIntersectionObserver = () => {
|
|||
};
|
||||
|
||||
watch(pageNums, (newPageNums) => {
|
||||
if(!initVuePdfEmbed.value) return
|
||||
pageVisibility.value = { [newPageNums[0]]: true }
|
||||
pageRefs.value = []
|
||||
nextTick(resetPageIntersectionObserver)
|
||||
});
|
||||
|
||||
watch(source, (newSource) => {
|
||||
if (isPDF.value) {
|
||||
pdfSource.value = newSource;
|
||||
}
|
||||
}
|
||||
);
|
||||
if(!initVuePdfEmbed.value) return
|
||||
pdfSource.value = isPDF.value ? newSource : null;
|
||||
});
|
||||
|
||||
const loadingProgress = computed(() => {
|
||||
if (isEventAttachment(item)) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue