Skip to content

Commit

Permalink
fix: indefinite animation when replacing current route
Browse files Browse the repository at this point in the history
  • Loading branch information
harsh253 committed Apr 21, 2024
1 parent 546c800 commit 0769b89
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ const NextTopLoader = ({
!shadow && shadow !== undefined
? ''
: shadow
? `box-shadow:${shadow}`
: `box-shadow:0 0 10px ${color},0 0 5px ${color}`;
? `box-shadow:${shadow}`
: `box-shadow:0 0 10px ${color},0 0 5px ${color}`;

// Check if to show at bottom
const positionStyle = showAtBottom ? 'bottom: 0;' : 'top: 0;';
Expand Down Expand Up @@ -270,7 +270,7 @@ const NextTopLoader = ({
}

/**
* Complete TopLoader Progress
* Complete TopLoader Progress on adding new entry to history stack
* @param {History}
* @returns {void}
*/
Expand All @@ -283,6 +283,20 @@ const NextTopLoader = ({
};
})((window as Window).history);

/**
* Complete TopLoader Progress on replacing current entry of history stack
* @param {History}
* @returns {void}
*/
((history: History): void => {
const replaceState = history.replaceState;
history.replaceState = (...args) => {
NProgress.done();
removeNProgressClass();
return replaceState.apply(history, args);
};
})((window as Window).history);

function handlePageHide(): void {
NProgress.done();
removeNProgressClass();
Expand Down

0 comments on commit 0769b89

Please sign in to comment.