Skip to content

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

@DEVTomatoCake

Description

@DEVTomatoCake

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions