Skip to content
This repository was archived by the owner on Jan 11, 2023. It is now read-only.

how to add navigator progress。 #248

Closed
MiYogurt opened this issue May 1, 2018 · 2 comments
Closed

how to add navigator progress。 #248

MiYogurt opened this issue May 1, 2018 · 2 comments

Comments

@MiYogurt
Copy link

MiYogurt commented May 1, 2018

I have a special love for navigator progress。how to Implement? i try use AOP program type override history.pushState but i find could not,error forbidden me to do that。Did not found router lifecycle hooks when i reading source code. emmm.... did you have any idea to solve it。

i think use setInterval listen the location.href is not good idea。 because i want show preload return data status 。eg. success is green style, error is red style。

@silentworks
Copy link
Contributor

Currently there are no hooks for the router, but this is something that is being discussed. You can follow this issue #157.

@Rich-Harris
Copy link
Member

This can be done with the top-level preloading property, which is true when you start navigating and false once it succeeds. In your root layout component you could do something like this:

// routes/_layout.html
{#if preloading}
  <Preloading/>
{/if}

<svelte:component this={child.component} {...child.props}/>

Typically you would only want to show a preloading indicator after ~250ms — many navigations will complete in under that time, and will feel instant, in which case an indicator feels unnecessarily jarring.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants