Skyleen77 / next-nprogress-bar

NProgress integration on Next.js compatible with /app and /pages folders
https://next-nprogress-bar.vercel.app
315 stars 24 forks source link

how to force the progress bar when navigating to the same url #50

Closed noobCode-69 closed 6 months ago

noobCode-69 commented 6 months ago

hey @Skyleen77 thanks for this awesome package

I only have one feature requirement .

image

something like this will be fine

if(// same url){
// start progress
// end progress
// rest of the logic
}
Skyleen77 commented 6 months ago

upgrade to the 2.3.10 and use disableSameURL={false} on the ProgressBar.

noobCode-69 commented 6 months ago

awesome thanks

noobCode-69 commented 6 months ago

hmmm it's not working it seems you have only added it for anchor elements but not for router.push

Skyleen77 commented 6 months ago

I'm sorry for that, I add a disableSameURL option on router.push() on the 2.3.11.

You can use it like this :

router.push('/url', undefined, { disableSameURL: false })
noobCode-69 commented 6 months ago

hmm i think it's still not working when i navigate to the same url the progress start but never end you will have to manually stop the progress bar since it's just a mock and this event window.history.pushState will not fire on same url navigation

Skyleen77 commented 6 months ago

It is normal that this does not stop because you are not changing pages, you can manually use the stopProgress function to stop it. To mock you can also use the startProgress function to launch the progress bar like this :

<button onClick={() => startProgress()}>Start progress</button>
<button onClick={() => stopProgress()}>Stop progress</button>

You can send me your code if you want so that we can find the best solution.