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

Optimize UI by only rendering what's visible #2627

Merged
merged 3 commits into from
Feb 29, 2024

Conversation

RunDevelopment
Copy link
Member

@RunDevelopment RunDevelopment commented Feb 28, 2024

This uses the react-intersection-observer package to implement an IfVisibile component. The idea is that replace elements that aren't visible with a placeholder to improve performance.

This has noticeably improved lag when:

  1. opening chainner,
  2. clearing a search query with few or no matches in the node selector panel,
  3. collapsing/expanding the node selector panel,
  4. opening the context selector pane,
  5. clearing a search query with few or no matches in the context selector pane, and
  6. opening the node documentation modal.

The IfVisibile is a bit hard to use in that it requires a height property. This needs to be the exact height of the content or else things will look funky. This is necessary to guarantee that the placeholder behaves exactly like the content. However, this restriction also allows it to further optimize layouting using the CSS contain property.

@joeyballentine
Copy link
Member

Played around with it and noticed that it does seem to cause some lag in the node selector sidebar if you scroll way too fast, but the other optimizations are worth that tradeoff

@joeyballentine joeyballentine merged commit 85a620f into chaiNNer-org:main Feb 29, 2024
7 checks passed
@RunDevelopment RunDevelopment deleted the intersection-opt branch February 29, 2024 11:59
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

Successfully merging this pull request may close these issues.

2 participants