@codeleap/web 3.13.0 → 3.13.2
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
|
@@ -25,6 +25,7 @@ import { ActionIcon, ActionIconProps } from '../ActionIcon'
|
|
|
25
25
|
import { Scroll } from '../Scroll'
|
|
26
26
|
import { ComponentCommonProps } from '../../types'
|
|
27
27
|
import { Touchable, TouchableProps } from '../Touchable'
|
|
28
|
+
import { useLockScroll } from '../../lib'
|
|
28
29
|
|
|
29
30
|
export * from './styles'
|
|
30
31
|
|
|
@@ -341,6 +342,8 @@ export const Modal = (props) => {
|
|
|
341
342
|
}
|
|
342
343
|
}, [visible])
|
|
343
344
|
|
|
345
|
+
useLockScroll(visible)
|
|
346
|
+
|
|
344
347
|
const content = <ModalContent {...props} id={modalId.current} />
|
|
345
348
|
|
|
346
349
|
// if (renderStatus === 'unmounted') return null
|
|
@@ -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,19 @@ 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 htmlElement = document.documentElement
|
|
359
|
+
|
|
360
|
+
if (htmlElement.style.overflowX !== 'hidden') {
|
|
361
|
+
htmlElement.style.overflowX = 'hidden'
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
if (isLock) {
|
|
365
|
+
htmlElement.style.overflowY = 'hidden'
|
|
366
|
+
} else {
|
|
367
|
+
htmlElement.style.overflowY = 'auto'
|
|
368
|
+
}
|
|
369
|
+
}, [isLock])
|
|
370
|
+
}
|