@@ -5,13 +5,17 @@ import { noScrollableParent, getScrollbarWidth } from '../helper/scroll.helper'
5
5
type ScrollParams = {
6
6
overlay : Ref < Element | undefined >
7
7
content : Ref < Element | undefined >
8
+ contentActiveClass : string
8
9
fullscreen : boolean
10
+ contentFullscreenClass : string
9
11
}
10
12
11
13
export const useScroll = ( {
12
14
overlay,
13
15
content,
16
+ contentActiveClass,
14
17
fullscreen,
18
+ contentFullscreenClass,
15
19
} : ScrollParams ) => {
16
20
let disabled = false
17
21
let disableType : 'byEvents' | 'byOverflow'
@@ -25,15 +29,17 @@ export const useScroll = ({
25
29
}
26
30
}
27
31
32
+ const scrollbarWidth = getScrollbarWidth ( )
33
+ const zeroScrollBar = scrollbarWidth === 0
34
+
28
35
const disableScroll = ( ) => {
29
36
if ( disabled ) {
30
37
return
31
38
}
32
39
33
- const scrollbarWidth = getScrollbarWidth ( )
34
-
35
- // The mobile has a scroll bar width of 0
36
- if ( scrollbarWidth === 0 || fullscreen ) {
40
+ // The mobile has the scroll bar width of 0
41
+ // hide the scroll bar for fullscreen mode
42
+ if ( zeroScrollBar || fullscreen ) {
37
43
disableType = 'byOverflow'
38
44
document . documentElement . classList . add ( 'overflow-y-hidden' )
39
45
} else {
@@ -54,7 +60,12 @@ export const useScroll = ({
54
60
if ( disableType === 'byEvents' ) {
55
61
window . removeEventListener ( 'wheel' , eventListener )
56
62
} else if ( disableType === 'byOverflow' ) {
57
- document . documentElement . classList . remove ( 'overflow-y-hidden' )
63
+ const activeContentElements = document . getElementsByClassName ( contentActiveClass )
64
+ const activeFullscreenContentElements = document . getElementsByClassName ( contentFullscreenClass )
65
+
66
+ if ( ( ! zeroScrollBar && fullscreen && activeFullscreenContentElements . length === 1 ) || activeContentElements . length === 1 ) {
67
+ document . documentElement . classList . remove ( 'overflow-y-hidden' )
68
+ }
58
69
}
59
70
60
71
disabled = false
0 commit comments