Skip to content

Commit

Permalink
resolve progress bar when page is served from bfcache
Browse files Browse the repository at this point in the history
  • Loading branch information
gbarnev committed Feb 11, 2024
1 parent f2a4e3d commit 44f7cea
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -220,13 +220,21 @@ const NextTopLoader = ({
NProgress.done();
}
}
function handlePageHide() {
NProgress.done();
[].forEach.call(npgclass, function (el: Element) {
el.classList.remove('nprogress-busy');
});
}

// Add the global click event listener
document.addEventListener('click', handleClick);
window.addEventListener('pagehide', handlePageHide);

// Clean up the global click event listener when the component is unmounted
return () => {
document.removeEventListener('click', handleClick);
window.removeEventListener('pagehide', handlePageHide);
};
}, []);

Expand Down

0 comments on commit 44f7cea

Please sign in to comment.