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

Make annotations list lazy load #156

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

windingwind
Copy link

Make the annotations list lazy load with the package react-intersection-observer. Now the annotation in the SidebarPreview only renders when it becomes visible. For PDF file with more than 10k annotations, loading time for annotations list is significantly improved (from several seconds to immediately); for the Better Note plugin's annotation header custom button API call, the UI do nor freeze (previously freeze for several minutes).

I also tried react-virtualized, but due to the following reasons that would bring some issue that I don't think can be easily solved:

  1. Since the annotation cells have dynamic height, the v-list's scroll-to does not promise a constant scrolling position, as the height of the previous cells would also affect the target cell's position
  2. Since the dynamic height cell's height is only known after rendering, there will be a short intermediate state where the UI first show a cell with initial height. This brings bad UI experience. (Maybe there are workarounds, I tried with GPT/Claud but no luck)
  3. The performance improvement is not significant comparing to the lazy load solution for me.

For the reasons above, I think we can just go with this PR and hopefully this will also decrease the memory usage of the reader.

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

Successfully merging this pull request may close these issues.

1 participant