diff --git a/packages/vkui/src/components/AppRoot/ScrollContext.tsx b/packages/vkui/src/components/AppRoot/ScrollContext.tsx index 3da20f9954..04ecd0839c 100644 --- a/packages/vkui/src/components/AppRoot/ScrollContext.tsx +++ b/packages/vkui/src/components/AppRoot/ScrollContext.tsx @@ -11,6 +11,7 @@ const clearDisableScrollStyle = (node: HTMLElement) => { top: '', left: '', right: '', + overscrollBehavior: '', overflowY: '', overflowX: '', }); @@ -93,9 +94,12 @@ export const GlobalScrollController = ({ children }: ScrollControllerProps): Rea top: `-${scrollY}px`, left: `-${scrollX}px`, right: '0', + overscrollBehavior: 'none', overflowY, overflowX, }); + // eslint-disable-next-line no-restricted-properties + document!.documentElement.classList.add('vkui--disable-overscroll-behavior'); setScrollLock(true); }, [document, window]); @@ -104,6 +108,8 @@ export const GlobalScrollController = ({ children }: ScrollControllerProps): Rea const scrollX = document!.body.style.left; clearDisableScrollStyle(document!.body); + // eslint-disable-next-line no-restricted-properties + document!.documentElement.classList.remove('vkui--disable-overscroll-behavior'); window!.scrollTo(-parseInt(scrollX || '0'), -parseInt(scrollY || '0')); setScrollLock(false); }, [document, window]); diff --git a/packages/vkui/src/components/CustomScrollView/CustomScrollView.module.css b/packages/vkui/src/components/CustomScrollView/CustomScrollView.module.css index 6b4412460c..49e6f862a1 100644 --- a/packages/vkui/src/components/CustomScrollView/CustomScrollView.module.css +++ b/packages/vkui/src/components/CustomScrollView/CustomScrollView.module.css @@ -3,6 +3,10 @@ block-size: 100%; overflow: hidden; position: relative; + + /* Для срабатывания `height: 100%` у `.CustomScrollView__box`, когда не во всех родителях есть `height: 100%`. */ + display: flex; + flex-direction: column; } .CustomScrollView__box { diff --git a/packages/vkui/src/components/ModalPage/ModalPageContext.tsx b/packages/vkui/src/components/ModalPage/ModalPageContext.tsx index 113dcc20a8..34b4f16e23 100644 --- a/packages/vkui/src/components/ModalPage/ModalPageContext.tsx +++ b/packages/vkui/src/components/ModalPage/ModalPageContext.tsx @@ -1,8 +1,8 @@ -import * as React from 'react'; +import { createContext } from 'react'; export interface ModalPageContextInterface { labelId?: string; } export const ModalPageContext: React.Context = - React.createContext({}); + createContext({}); diff --git a/packages/vkui/src/components/ModalPageBackdrop/ModalPageBackdrop.module.css b/packages/vkui/src/components/ModalPageBackdrop/ModalPageBackdrop.module.css new file mode 100644 index 0000000000..23644de52b --- /dev/null +++ b/packages/vkui/src/components/ModalPageBackdrop/ModalPageBackdrop.module.css @@ -0,0 +1,28 @@ +.ModalPageBackdrop { + position: absolute; + inset: 0; + z-index: -1; + background-color: rgba(0, 0, 0); + opacity: 0.4; + user-select: none; + -webkit-tap-highlight-color: transparent; +} + +.ModalPageBackdrop--visible { + animation: modal-page-backdrop-fade-in 0.2s ease-in; +} + +.ModalPageBackdrop--invisible { + animation: modal-page-backdrop-fade-out 0.1s ease-out forwards; +} + +@keyframes modal-page-backdrop-fade-in { + from { + opacity: 0; + } +} +@keyframes modal-page-backdrop-fade-out { + to { + opacity: 0; + } +} diff --git a/packages/vkui/src/components/ModalPageBackdrop/ModalPageBackdrop.tsx b/packages/vkui/src/components/ModalPageBackdrop/ModalPageBackdrop.tsx new file mode 100644 index 0000000000..70f91b3cf0 --- /dev/null +++ b/packages/vkui/src/components/ModalPageBackdrop/ModalPageBackdrop.tsx @@ -0,0 +1,22 @@ +import { classNames } from '@vkontakte/vkjs'; +import type { HasRootRef } from '../../types'; +import styles from './ModalPageBackdrop.module.css'; + +export interface ModalPageBackdropProps extends HasRootRef { + visible: boolean; + onClick?: (event: React.MouseEvent) => void; +} + +export const ModalPageBackdrop = ({ visible, getRootRef, onClick }: ModalPageBackdropProps) => { + return ( +