JuliaPluto / PlutoUI.jl

https://featured.plutojl.org/basic/plutoui.jl
The Unlicense
299 stars 54 forks source link

TableOfContents title flickering while notebook is loading #287

Open fonsp opened 4 months ago

fonsp commented 4 months ago

https://github.com/JuliaPluto/PlutoUI.jl/assets/6933510/fa95bf6e-dd5f-4599-8a24-1df64e327596

Will be fixed s00n by @beramos

Beramos commented 4 months ago

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 https://github.com/JuliaPluto/PlutoUI.jl/blob/1798c47e5b413c18e7b3e066956530f1a1da1df9/src/TableOfContents.jl#L138

The in-view-class is removed on every intersection_callback. During scrolling, the InteractionObserver executes this callback -> https://github.com/JuliaPluto/PlutoUI.jl/blob/1798c47e5b413c18e7b3e066956530f1a1da1df9/src/TableOfContents.jl#L167-L178 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 https://github.com/JuliaPluto/PlutoUI.jl/blob/1798c47e5b413c18e7b3e066956530f1a1da1df9/src/TableOfContents.jl#L239-L245) (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 commented 4 months ago

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