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