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,
});
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)) {