Skip to content

Commit 0b17b3c

Browse files
authored
Merge pull request #76 from harsh253/master
fix: indefinite animation when replacing current route
2 parents 546c800 + 0769b89 commit 0b17b3c

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

src/index.tsx

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ const NextTopLoader = ({
112112
!shadow && shadow !== undefined
113113
? ''
114114
: shadow
115-
? `box-shadow:${shadow}`
116-
: `box-shadow:0 0 10px ${color},0 0 5px ${color}`;
115+
? `box-shadow:${shadow}`
116+
: `box-shadow:0 0 10px ${color},0 0 5px ${color}`;
117117

118118
// Check if to show at bottom
119119
const positionStyle = showAtBottom ? 'bottom: 0;' : 'top: 0;';
@@ -270,7 +270,7 @@ const NextTopLoader = ({
270270
}
271271

272272
/**
273-
* Complete TopLoader Progress
273+
* Complete TopLoader Progress on adding new entry to history stack
274274
* @param {History}
275275
* @returns {void}
276276
*/
@@ -283,6 +283,20 @@ const NextTopLoader = ({
283283
};
284284
})((window as Window).history);
285285

286+
/**
287+
* Complete TopLoader Progress on replacing current entry of history stack
288+
* @param {History}
289+
* @returns {void}
290+
*/
291+
((history: History): void => {
292+
const replaceState = history.replaceState;
293+
history.replaceState = (...args) => {
294+
NProgress.done();
295+
removeNProgressClass();
296+
return replaceState.apply(history, args);
297+
};
298+
})((window as Window).history);
299+
286300
function handlePageHide(): void {
287301
NProgress.done();
288302
removeNProgressClass();

0 commit comments

Comments
 (0)