Skip to content

feat: remove resize debounce, and move to batch system for rerendering #89

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

BeksOmega
Copy link

Fixes: None I think

  1. Removes the debounce timeout from the resize observer, because I think this can actually be performant enough it doesn't need it. (Another way to think about this is debouncing is forcing
    jank, if we remove the debounce, then the jank is caused by browser performance rather than a hard-coded implementation)
  2. Moves to a batch rendering system based on requestAnimationFrame so that we're doing all recalculation at once instead of in individual callbacks.
  3. Splits the dom computation from the dom manipulation so that we're not forcing layout calculations.
  4. Optimizes the rendering so that if the element only moved and didn't change size, we just reuse the existing SVG instead of removing it and inserting a new one.

Profiling

Attached two performance profiles (with 4x CPU throttling enabled, as recommended). "resize" is a performance log for actually resizing the buttons the annotations are associated with. "move" is a peformance log for making the buttons move by changing the browser size.

move-profile.json
resize-profile.json

Testing

Didn't super thoroughly test this because I wanted to know if it was likely to get merged before I invested more time (since I know it's a big change). Let me know what you think and I can try to find time to hammer it more!

Base branch

I know I'm branched off my other branch atm haha. Just didn't want to duplicate changes and conflict with myself, assuming that other one gets merged.

google-labs-jules bot and others added 5 commits August 9, 2025 04:48
This change introduces an animation to the `hide()` method, making the annotation disappear with a reverse animation of the `show()` method.

Previously, `hide()` would immediately remove the annotation's SVG elements from the DOM. This change modifies the `hide()` method to:
- Play the `show()` animation in reverse.
- Use `requestAnimationFrame` to ensure the animation restart is smooth.
- Use `setTimeout` to remove the SVG elements only after the animation has completed. This prevents race conditions when `show()` is called again while a `hide()` animation is in progress.

This addresses issue rough-stuff#57.
This commit adds a `demo.html` file to showcase the animated `hide()` functionality. This allows for easy local testing and verification of the feature.
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.

1 participant