uncomment observers
This commit is contained in:
parent
4223a9d522
commit
1e890cfa2e
1 changed files with 37 additions and 32 deletions
|
|
@ -50,38 +50,43 @@ const currentPageIndex = ref(1);
|
||||||
|
|
||||||
// Functions
|
// Functions
|
||||||
const onPdfLoaded = () => {
|
const onPdfLoaded = () => {
|
||||||
// const wrapper = document.querySelector('.vpv-pages-inner-container');
|
const wrapper = document.querySelector('.vpv-pages-inner-container');
|
||||||
// const observer = new IntersectionObserver(
|
|
||||||
// (entries) => {
|
const observer = new IntersectionObserver(
|
||||||
// entries.forEach((entry, index) => {
|
(entries) => {
|
||||||
// if (entry.intersectionRatio > 0.5) {
|
entries.forEach((entry, index) => {
|
||||||
// currentPageIndex.value = parseInt(
|
if (entry.intersectionRatio > 0.5) {
|
||||||
// entry.target.getAttribute('aria-label').split(' ')[1]
|
currentPageIndex.value = parseInt(
|
||||||
// );
|
entry.target.getAttribute('aria-label').split(' ')[1]
|
||||||
// }
|
);
|
||||||
// });
|
}
|
||||||
// },
|
});
|
||||||
// {
|
},
|
||||||
// root: wrapper,
|
{
|
||||||
// threshold: [0.5],
|
root: wrapper,
|
||||||
// }
|
threshold: [0.5],
|
||||||
// );
|
}
|
||||||
// const observePages = () => {
|
);
|
||||||
// const pages = document.querySelectorAll('.vpv-page-inner-container');
|
|
||||||
// pages.forEach((page) => {
|
const observePages = () => {
|
||||||
// if (!page.__observed__) {
|
const pages = document.querySelectorAll('.vpv-page-inner-container');
|
||||||
// observer.observe(page);
|
pages.forEach((page) => {
|
||||||
// page.__observed__ = true;
|
if (!page.__observed__) {
|
||||||
// }
|
observer.observe(page);
|
||||||
// });
|
page.__observed__ = true;
|
||||||
// };
|
}
|
||||||
// const mutationObserver = new MutationObserver(() => {
|
});
|
||||||
// observePages();
|
};
|
||||||
// });
|
|
||||||
// if (wrapper) {
|
const mutationObserver = new MutationObserver(() => {
|
||||||
// mutationObserver.observe(wrapper, { childList: true, subtree: true });
|
observePages();
|
||||||
// }
|
});
|
||||||
// observePages();
|
|
||||||
|
if (wrapper) {
|
||||||
|
mutationObserver.observe(wrapper, { childList: true, subtree: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
observePages();
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue