@codeleap/web 3.13.1 → 3.13.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -332,20 +332,12 @@ export const Modal = (props) => {
|
|
|
332
332
|
appRoot.setAttribute('tabindex', `${-1}`)
|
|
333
333
|
}
|
|
334
334
|
|
|
335
|
-
const htmlElement = document.documentElement
|
|
336
|
-
|
|
337
335
|
if (visible) {
|
|
338
336
|
document.body.style.overflowY = 'hidden'
|
|
339
337
|
document.body.style.overflowX = 'hidden'
|
|
340
|
-
|
|
341
|
-
htmlElement.style.overflowX = 'hidden'
|
|
342
|
-
htmlElement.style.overflowY = 'hidden'
|
|
343
338
|
} else {
|
|
344
339
|
document.body.style.overflowY = 'visible'
|
|
345
340
|
document.body.style.overflowX = 'hidden'
|
|
346
|
-
|
|
347
|
-
htmlElement.style.overflowX = 'hidden'
|
|
348
|
-
htmlElement.style.overflowY = 'auto'
|
|
349
341
|
}
|
|
350
342
|
}, [visible])
|
|
351
343
|
|
|
@@ -8,7 +8,7 @@ import { Touchable, TouchableProps } from '../Touchable'
|
|
|
8
8
|
import { View, ViewProps } from '../View'
|
|
9
9
|
import { OverlayComposition, OverlayPresets } from './styles'
|
|
10
10
|
import { NativeHTMLElement } from '../../types'
|
|
11
|
-
import { usePopState } from '../../lib'
|
|
11
|
+
import { useLockScroll, usePopState } from '../../lib'
|
|
12
12
|
|
|
13
13
|
export type OverlayProps<T extends NativeHTMLElement = 'div'> = {
|
|
14
14
|
visible?: boolean
|
|
@@ -37,6 +37,8 @@ export const Overlay = <T extends NativeHTMLElement>(overlayProps:OverlayProps<T
|
|
|
37
37
|
|
|
38
38
|
usePopState(visible, props.onPress, scrollLocked)
|
|
39
39
|
|
|
40
|
+
useLockScroll(visible)
|
|
41
|
+
|
|
40
42
|
const Component = props.onClick || props.onPress ? Touchable : View
|
|
41
43
|
|
|
42
44
|
return (
|
package/src/lib/hooks.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AnyFunction, onMount, onUpdate, range, useUncontrolled } from '@codeleap/common'
|
|
1
|
+
import { AnyFunction, onMount, onUpdate, range, useIsomorphicEffect, useUncontrolled } from '@codeleap/common'
|
|
2
2
|
import { useCallback, useMemo, useRef, useState } from 'react'
|
|
3
3
|
import { v4 } from 'uuid'
|
|
4
4
|
import { easeInOut, EasingFunction, AnimationProps, useAnimate, useAnimation, animate } from 'framer-motion'
|
|
@@ -352,3 +352,23 @@ export function useAnimatedVariantStyles<T extends Record<string|number|symbol,
|
|
|
352
352
|
|
|
353
353
|
return animated
|
|
354
354
|
}
|
|
355
|
+
|
|
356
|
+
export function useLockScroll(isLock: boolean) {
|
|
357
|
+
useIsomorphicEffect(() => {
|
|
358
|
+
const htmlStyle = document?.documentElement?.style
|
|
359
|
+
|
|
360
|
+
if (!!htmlStyle) {
|
|
361
|
+
if (htmlStyle.overflowX !== 'hidden') {
|
|
362
|
+
htmlStyle.overflowX = 'hidden'
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
console.log({ isLock, flow: htmlStyle.overflowY })
|
|
366
|
+
|
|
367
|
+
if (isLock) {
|
|
368
|
+
htmlStyle.overflowY = 'hidden'
|
|
369
|
+
} else if (!isLock && htmlStyle.overflowY === 'hidden') {
|
|
370
|
+
htmlStyle.overflowY = 'auto'
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
}, [isLock])
|
|
374
|
+
}
|