Replies: 1 comment
-
Not sure if this is what's causing the issue but you can try executing your observer logic in client side: if (process.client) {
observer.value = new IntersectionObserver((entries) => {
entries.forEach((entry) => {
const id = entry.target.getAttribute('id');
if (entry.isIntersecting) {
activeTocId.value = id;
}
});
}, observerOptions);
document
.querySelectorAll('.building-content h2[id], .building-content h3[id]')
.forEach((section) => {
observer.value?.observe(section);
});
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
I am using nuxt3 with nuxt-content on a document-driven approach.
This way I got:
/content
-directory where I store markdown-filesWithin my layout, I got this:
This works well - until I am clicking one of the
nuxt-link
. In this case, the intersection observer within the table of content does no longer work. It's just "stuck" at the position where I was when I left the page.Refreshing the page using CTRL + R makes the intersection observer work again.
Now I am wondering: Although the
onUnmounted
function is being triggered clicking thenuxt-link
, it seems like the intersection observer is not correctly initialized after that. Can anybody help me to understand this behavior?Beta Was this translation helpful? Give feedback.
All reactions