File tree Expand file tree Collapse file tree 1 file changed +3
-2
lines changed Expand file tree Collapse file tree 1 file changed +3
-2
lines changed Original file line number Diff line number Diff line change @@ -16,12 +16,13 @@ export function useBodyNoScroll(overlayRef: {current: HTMLDivElement | null}) {
16
16
17
17
const initialBodyClassList = body . classList . value ;
18
18
const initialBodyStyleTop = body . style . top ;
19
+ const initialScrollY = window . scrollY ;
19
20
20
21
if ( initialBodyClassList . includes ( NO_SCROLL_CLASS ) ) {
21
22
return ;
22
23
}
23
24
24
- body . style . top = `-${ window . scrollY } px` ;
25
+ body . style . top = `-${ initialScrollY } px` ;
25
26
body . classList . add ( NO_SCROLL_CLASS ) ;
26
27
27
28
const cleanup = ( ) => {
@@ -30,7 +31,7 @@ export function useBodyNoScroll(overlayRef: {current: HTMLDivElement | null}) {
30
31
31
32
body . style . top = initialBodyStyleTop ;
32
33
body . className = initialBodyClassList ;
33
- window . scrollTo ( 0 , scrollY ) ;
34
+ window . scrollTo ( 0 , initialScrollY ) ;
34
35
} ;
35
36
36
37
// @ts -ignore TS2322
You can’t perform that action at this time.
0 commit comments