33 *
44 * @param target (Optional) The target HTMLElement. Default: `Document.documentElement`.
55 */
6- export const blockScroll = ( target ? : HTMLElement ) => {
6+ export const blockScroll = ( target : HTMLElement = document . documentElement ) => {
77
8- const el = target || document . documentElement
9- const { width } = el . getBoundingClientRect ( )
10- el . style . overflow = 'hidden'
11- const scrollBarSize = el . clientWidth - width
8+ const { width } = target . getBoundingClientRect ( )
9+ target . style . overflow = 'hidden'
10+ const scrollBarSize = target . clientWidth - width
1211
13- el . style . paddingRight = `${ scrollBarSize } px`
14- el . style . setProperty ( '--scrollbar-size' , `${ scrollBarSize } px` )
12+ target . style . paddingRight = `${ scrollBarSize } px`
13+ target . style . setProperty ( '--scrollbar-size' , `${ scrollBarSize } px` )
1514
1615}
1716
@@ -21,12 +20,10 @@ export const blockScroll = ( target?: HTMLElement ) => {
2120 *
2221 * @param target (Optional) The target HTMLElement. Default: `Document.documentElement`.
2322 */
24- export const restoreScroll = ( target ?: HTMLElement ) => {
25-
26- const el = target || document . documentElement
23+ export const restoreScroll = ( target : HTMLElement = document . documentElement ) => {
2724
28- el . style . removeProperty ( 'overflow' )
29- el . style . removeProperty ( 'padding-right' )
30- el . style . removeProperty ( '--scrollbar-size' )
25+ target . style . removeProperty ( 'overflow' )
26+ target . style . removeProperty ( 'padding-right' )
27+ target . style . removeProperty ( '--scrollbar-size' )
3128
3229}
0 commit comments