File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed
packages/core/useScrollLock Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -44,6 +44,8 @@ function preventDefault(rawEvent: TouchEvent): boolean {
44
44
return false
45
45
}
46
46
47
+ const elInitialOverflow = new WeakMap < HTMLElement , CSSStyleDeclaration [ 'overflow' ] > ( )
48
+
47
49
/**
48
50
* Lock scrolling of the element.
49
51
*
@@ -62,7 +64,8 @@ export function useScrollLock(
62
64
const target = resolveElement ( toValue ( el ) )
63
65
if ( target ) {
64
66
const ele = target as HTMLElement
65
- initialOverflow = ele . style . overflow
67
+ if ( ! elInitialOverflow . get ( ele ) )
68
+ elInitialOverflow . set ( ele , initialOverflow )
66
69
if ( isLocked . value )
67
70
ele . style . overflow = 'hidden'
68
71
}
@@ -91,7 +94,8 @@ export function useScrollLock(
91
94
if ( ! el || ! isLocked . value )
92
95
return
93
96
isIOS && stopTouchMoveListener ?.( )
94
- el . style . overflow = initialOverflow
97
+ el . style . overflow = elInitialOverflow . get ( el as HTMLElement ) ?? ''
98
+ elInitialOverflow . delete ( el as HTMLElement )
95
99
isLocked . value = false
96
100
}
97
101
You can’t perform that action at this time.
0 commit comments