Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TableOfContents title flickering while notebook is loading #287

Open
fonsp opened this issue Feb 6, 2024 · 2 comments
Open

TableOfContents title flickering while notebook is loading #287

fonsp opened this issue Feb 6, 2024 · 2 comments

Comments

@fonsp
Copy link
Member

fonsp commented Feb 6, 2024

Schermopname.2024-02-06.om.14.57.54.mov

Will be fixed s00n by @Beramos

@Beramos
Copy link

Beramos commented Feb 6, 2024

I dove into this issue, I was not yet able to implement a fix but I'm documenting progress here.

The origin of the problem is

currently_highlighted_set.forEach(a => a.classList.remove("in-view"))

The in-view-class is removed on every intersection_callback. During scrolling, the InteractionObserver executes this callback ->

let intersection_observer_1 = new IntersectionObserver(intersection_callback, {
root: null, // i.e. the viewport
threshold: 1,
rootMargin: "-15px", // slightly smaller than the viewport
// delay: 100,
})
let intersection_observer_2 = new IntersectionObserver(intersection_callback, {
root: null, // i.e. the viewport
threshold: 1,
rootMargin: "15px", // slightly larger than the viewport
// delay: 100,
})
which works fine since every callback seems to result in change of the <a>-tag that receives the in-view-class.

Now the problem arises when the intersection_callback is called from UpdateCallback

const updateCallback = () => {
if (!invalidated.current) {
tocNode.querySelector("section").replaceWith(
html`<section>\${render(getHeaders())}</section>`
)
}
}
) (which happens quite often). Because the highlight is always removed during an intersection_callback this results in the flickering effect.

I'll try to think about an elegant solution (suggestions are welcome) if I have some time tomorrow.

@fonsp
Copy link
Member Author

fonsp commented Feb 7, 2024

Perhaps you can use this to persist some data inbetween the renders? Check out the "Stateful output with this" in https://featured.plutojl.org/web/javascript

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants