Skip to content

Commit 6887433

Browse files
committed
www(доработка имеющегося функционала): add delay before change anchor
add delay before change anchor
1 parent 304cb5e commit 6887433

File tree

2 files changed

+19
-17
lines changed

2 files changed

+19
-17
lines changed

www/components/driver-content-nav/DriverContentNav.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ export const DriverContentNav = observer<IDriverContentNav>( ( { className } ) =
3030

3131
// event.preventDefault();
3232

33-
console.log( `CHANGE_PAGE_POSITION` );
3433
// let link = event.target as HTMLLinkElement;
3534
// let elementId = link.href.replace( /(.*)?#/, `` );
3635
// let element = document.getElementById( decodeURIComponent( elementId ) ) as HTMLElement;

www/hooks/content-autoscroll-hook.ts

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,28 @@ export function useContentAutoscroll(){
88

99
useEffect(() => {
1010
function scrollHandler() {
11-
if (window.scrollX === 0) {
12-
window.removeEventListener("scroll", scrollHandler);
13-
14-
// hack for mobile
15-
setTimeout(()=>{
16-
if ( scrollX > 0 ) {
17-
document.scrollingElement.scrollLeft = 0;
18-
}
19-
})
20-
21-
return;
22-
}
23-
document.scrollingElement.scrollLeft = 0;
11+
// if (window.scrollX === 0) {
12+
// window.removeEventListener("scroll", scrollHandler);
13+
//
14+
// // hack for mobile
15+
// setTimeout(()=>{
16+
// if ( scrollX > 0 ) {
17+
// document.scrollingElement.scrollLeft = 0;
18+
// }
19+
// })
20+
//
21+
// return;
22+
// }
23+
// document.scrollingElement.scrollLeft = 0;
2424
}
2525

2626
function startHashChangeHandler() {
27-
let hash = location.hash.slice( 1 );
28-
goToAnchor( hash );
29-
window.addEventListener("scroll", scrollHandler);
27+
setTimeout( () => {
28+
let hash = location.hash.slice( 1 );
29+
30+
goToAnchor( hash );
31+
window.addEventListener( "scroll", scrollHandler );
32+
}, 100 );
3033
}
3134

3235
window.addEventListener("scroll", scrollHandler);

0 commit comments

Comments
 (0)