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

Lags when scrolling on a page with TOC and a large number of headings #147

Closed
atlz253 opened this issue Jun 23, 2024 · 6 comments · Fixed by #148
Closed

Lags when scrolling on a page with TOC and a large number of headings #147

atlz253 opened this issue Jun 23, 2024 · 6 comments · Fixed by #148
Labels
bug Something isn't working

Comments

@atlz253
Copy link

atlz253 commented Jun 23, 2024

Hi! We use Doxygen Awesome on the userver documentation site. Unfortunately, on pages with a large number of headings, there is a slowdown when scrolling down the page. Similar behavior can be seen on this page.

The slowdown is due to the updating of classes at the TOC headers, I tried to show this in the video. It would be cool to fix this loss of performance.

output.compress-video-online.com.mp4
@atlz253 atlz253 changed the title Lags when working with TOC on a page with a large number of headings Lags when scrolling on a page with TOC and a large number of headings Jun 23, 2024
@iamAyushChamoli
Copy link
Contributor

The update() function in doxygen-awesome-interactive-toc.js is being called on every scroll event. This results in a significant performance delay. We can batch the class change events after exiting the loop if that works, or maybe call the update() function in a scheduled manner (every 50ms or so). I have a potential solution but unsure how to test it. Can I create a pull request for your review?

@atlz253
Copy link
Author

atlz253 commented Jul 2, 2024

@iamAyushChamoli Yes, I can review and test changes. It will be very cool!

@jothepro jothepro added the bug Something isn't working label Jul 3, 2024
@jothepro
Copy link
Owner

jothepro commented Jul 3, 2024

I'd really appreciate if you open a pull request with a suggestion on how to fix this, @iamAyushChamoli. :)

@iamAyushChamoli
Copy link
Contributor

Hi, @jothepro & @atlz253, created a pull request for the same. Introduced throttling of the update() function to enhance UX by reducing function calls. This is my first pull request so let me know if I accidentally messed something up.

@atlz253
Copy link
Author

atlz253 commented Jul 4, 2024

@iamAyushChamoli upload before/after comparison. It became much smoother! Congratulations on your first contribution!

One moment. This line is missing the keyword "this". It should be like: document.getElementById("doc-content")?.addEventListener("scroll", this.throttle(DoxygenAwesomeInteractiveToc.update, 100)). Otherwise, the fix does not work :(

2024-07-05.02-32-44_compressed.mp4

@iamAyushChamoli
Copy link
Contributor

@jothepro I have updated the code and included "this" keyword as you suggested, please review the code and let me know if it works well now!
btw Thanks! this is quite pleasant to have my first pull request accepted :D

jothepro added a commit that referenced this issue Jul 9, 2024
reduces the number of TOC refreshes by throttling calls to the DoxygenAwesomeInteractiveToc.update() method.

Fixes #147

Co-authored-by: jothepro <github@jothe.pro>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants