This repository has been archived by the owner on Nov 9, 2024. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Ok so this is weird..
I originally used
delay: [0, 20]
as the default because Chrome had thistransitionend
issue where it fires 1 frame too late sometimes. It's not a memory leak or bug, just an aesthetic thing.Using a delay of 20ms fixed the following: When mousing out of the element 1 frame before the tooltip fully showed, it would instantly be unmounted without transitioning out. When mousing in and out of the tooltip quickly it would sometimes unmount instantly rather than smoothly transition out (like interruptible animations should). It's not that big of a deal but kind of bothered me.
However now there's this strange bug where the hide
setTimeout
gets fired really late despite only being 20ms by default. Like 1500ms+ and it leaves the tooltip stuck on the UI for a bit. And it's really hard to reproduce because it only happens 1/50 times or so, requires a page refresh, etc. It might even be something to do with Gatsby.I tested and confirmed that the timeout callback is being fired very late. I only found this issue https://stackoverflow.com/questions/35102791/stuck-settimeouts-chrome
What this change does is remove
setTimeout
scheduling by default and instead userequestAnimationFrame
which doesn't seem to suffer from the late scheduling problem. This won't fix the late scheduling when you set a non-zero hide delay though...