@@ -26,7 +26,7 @@ function getElAndScroll() {
26
26
return false ;
27
27
}
28
28
29
- function hashLinkScroll ( ) {
29
+ function hashLinkScroll ( timeout ) {
30
30
// Push onto callback queue so it runs after the DOM is updated
31
31
window . setTimeout ( ( ) => {
32
32
if ( getElAndScroll ( ) === false ) {
@@ -38,10 +38,10 @@ function hashLinkScroll() {
38
38
childList : true ,
39
39
subtree : true ,
40
40
} ) ;
41
- // if the element doesn't show up in 10 seconds, stop checking
41
+ // if the element doesn't show up in specified timeout or 10 seconds, stop checking
42
42
asyncTimerId = window . setTimeout ( ( ) => {
43
43
reset ( ) ;
44
- } , 10000 ) ;
44
+ } , timeout || 10000 ) ;
45
45
}
46
46
} , 0 ) ;
47
47
}
@@ -69,10 +69,10 @@ export function genericHashLink(As) {
69
69
props . smooth
70
70
? el . scrollIntoView ( { behavior : "smooth" } )
71
71
: el . scrollIntoView ( ) ) ;
72
- hashLinkScroll ( ) ;
72
+ hashLinkScroll ( props . timeout ) ;
73
73
}
74
74
}
75
- const { scroll, smooth, ...filteredProps } = props ;
75
+ const { scroll, smooth, timeout , ...filteredProps } = props ;
76
76
return (
77
77
< As { ...filteredProps } onClick = { handleClick } ref = { ref } >
78
78
{ props . children }
@@ -89,6 +89,7 @@ const propTypes = {
89
89
onClick : PropTypes . func ,
90
90
children : PropTypes . node ,
91
91
scroll : PropTypes . func ,
92
+ timeout : PropTypes . number ,
92
93
to : PropTypes . oneOfType ( [ PropTypes . string , PropTypes . object ] ) ,
93
94
} ;
94
95
0 commit comments