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

"Delay on hover" working in an unexpected way #124

Open
DEVTomatoCake opened this issue Jan 22, 2024 · 0 comments
Open

"Delay on hover" working in an unexpected way #124

DEVTomatoCake opened this issue Jan 22, 2024 · 0 comments

Comments

@DEVTomatoCake
Copy link

To me, https://instant.page/intensity#:~:text=Adjusting%20the%20delay%20on%20hover isn't really clear what exactly adjusting the value does.

I'd assume that if a user hovers over a link, but un-hovers within the specified time in milliseconds, nothing would get preloaded.

However, this isn't the case when hovering over multiple links within a short time, or re-hovering over the same link again.

_mouseoverTimer = setTimeout(() => {

causes the variable to be overwritten while it may still be needed for a different link.

Because the timeout ID was overwritten, clearing it has no effect if more than one link has been hovered over within the configured time:

clearTimeout(_mouseoverTimer)

Reproduction

This can be easily seen by using <body data-instant-intensity="1000"> - when hovering over multiple links, despite having un-hovered them, they are still preloaded after one second.

Potential solution

Instead of using a variable which only stores one timeout ID at a time, the script should use an Object/a Map to keep track of the URLs having a timeout, and the timeout ID for clearing it.

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

No branches or pull requests

1 participant