-
Notifications
You must be signed in to change notification settings - Fork 304
core: debounce hover recheck after hit-grid changes #502
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
Conversation
0d3702f to
2cc4b63
Compare
- track hit-grid dirty on layout/translate/visibility/z-index changes - schedule post-frame hover rechecks with debounce and move/drag cancel
…ates Debounced hover rechecks to avoid stale pointer payloads and re-entrancy, and made z-index flips trigger a frame so hit/hover updates land reliably after render.
2cc4b63 to
35594df
Compare
|
I didn't want the manual
Impact on frame budget:
Could be slightly improved by exposing an FFI method to |
I think this is a fair trade-off, with debounce removed, hover rechecks now run immediately after every render when the hit grid changes, but we don't have to track this + extra complexity. |
So, the core issue was that scrolling or animating elements left the hover state stale because we were only running hit tests on actual mouse movement. If the element moved but the mouse didn't, we wouldn't catch it.
To fix this without tanking performance during scroll, we implemented a dirty-flag + debounce system:
Dirty Tracking: I added a hitGridDirty flag to the renderer. Now, whenever a Renderable changes a property that affects hit testing (translateX/Y, zIndex, visible, overflow, or layout shifts), it calls markHitGridDirty().
Debounced Recheck: At the end of the render loop, if the grid is dirty, we schedule a debounced hover recheck. This groups many updates into a single check instead of running hit logic every frame.
Synthetic Events: The recheck uses the last known pointer position. If the target under the cursor changes, we fire out and over events to update the UI.
I cancel this check if the user moves the mouse, since that triggers an immediate test. It's also skipped during drags to avoid messing with drop targets.