check initVuePdfEmbed before intersectionobserver API

This commit is contained in:
10G Meow 2025-11-03 14:46:03 +02:00
parent 28865658d2
commit 6cb4984e46

View file

@ -153,11 +153,14 @@ const { doc } = useVuePdfEmbed({
source: pdfSource, source: pdfSource,
}); });
const initVuePdfEmbed = computed(()=> props.showInlinePDF && isPDF.value)
const pageNums = computed(() => const pageNums = computed(() =>
doc.value ? [...Array(doc.value.numPages + 1).keys()].slice(1) : [] doc.value ? [...Array(doc.value.numPages + 1).keys()].slice(1) : []
); );
const resetPageIntersectionObserver = () => { const resetPageIntersectionObserver = () => {
if(!initVuePdfEmbed.value) return
pageIntersectionObserver?.disconnect() pageIntersectionObserver?.disconnect()
pageIntersectionObserver = new IntersectionObserver((entries) => { pageIntersectionObserver = new IntersectionObserver((entries) => {
entries.forEach((entry) => { entries.forEach((entry) => {
@ -177,17 +180,16 @@ const resetPageIntersectionObserver = () => {
}; };
watch(pageNums, (newPageNums) => { watch(pageNums, (newPageNums) => {
if(!initVuePdfEmbed.value) return
pageVisibility.value = { [newPageNums[0]]: true } pageVisibility.value = { [newPageNums[0]]: true }
pageRefs.value = [] pageRefs.value = []
nextTick(resetPageIntersectionObserver) nextTick(resetPageIntersectionObserver)
}); });
watch(source, (newSource) => { watch(source, (newSource) => {
if (isPDF.value) { if(!initVuePdfEmbed.value) return
pdfSource.value = newSource; pdfSource.value = isPDF.value ? newSource : null;
} });
}
);
const loadingProgress = computed(() => { const loadingProgress = computed(() => {
if (isEventAttachment(item)) { if (isEventAttachment(item)) {