@yandex/ui
Version:
Yandex UI components
28 lines (27 loc) • 864 B
TypeScript
import { RefObject } from 'react';
export interface UsePreventScrollOptions {
/**
* Включает/отключает прокрутку у элемента.
*/
enabled: boolean | undefined;
/**
* Ссылка на DOM-элемент, у которого нужно заблокировать прокрутку.
*
* @default document.body
*/
containerRef?: RefObject<HTMLElement>;
}
/**
* Реакт-хук, запрещающий прокрутку содержимого на элементе.
*
* @example
* const Modal: FC<ModalProps> = (props) => {
* const { visible } = props;
* const containerRef = useRef(document.documentElement);
*
* usePreventScroll({ enabled: visible, containerRef });
*
* ...
* }
*/
export declare function usePreventScroll(options: UsePreventScrollOptions): void;