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

prefetchEvents option #27

Open
andrepimpao opened this issue Dec 2, 2024 · 2 comments
Open

prefetchEvents option #27

andrepimpao opened this issue Dec 2, 2024 · 2 comments

Comments

@andrepimpao
Copy link

It would be interesting to have an option to set the events to trigger a link preload when enablePrefetch is set to true.

I know that it is possible to set the enablePrefetch to false and then use the API preload() method, but it would be so much easier for simple cases, like adding a touchstart event for touch devices.

Something like:

const taxi = new Core({ 
    // default
    // prefetchEvents: 'mouseenter focus'

    // on "tap" only
    // prefetchEvents: 'mousedown touchstart'

    // add "touchstart" for touch devices
    prefetchEvents: 'mouseenter focus touchstart'
});

Thank you.

@jakewhiteley
Copy link
Member

@andrepimpao I am happy to add, but copuld I ask what the usecase of touchstart would be?

I was going to add this originally, but then figured the touchstart event would be fired at effectively the same time as the click event, so by that point the transition is already starting.

@andrepimpao
Copy link
Author

@jakewhiteley oh, I was assuming that you would only request the new page between the onLeaveCompleted and onEnter events. So I was suggesting having a touchstart to prefetch the page upon touching the link (since there is no mouseenter on touch devices), but I see now that the request is made immediately after the onLeave event.

My usecase does not apply here then. I can't think of any other usecases, so I guess this option is not needed at all, since there is already an alternative with the preload method for edge cases.

Thank you.

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

2 participants