/
githubmr
/
facebook-react
Обзор
Документация
Войти
/
githubmr
/
facebook-react
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
main
packages/react-devtools-timeline/src/view-base/vertical-scroll-overflow/withVerticalScrollbarLayout.js
55 строк
1 KB
Jan Kassens
Update Flow to 0.279 (#34277)
25 авг 2025, 18:02
Не верифицирован
25 авг 2025, 18:02
df10309
Код
Авторство
О чём код?
/** * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import type {LayoutInfo, Layouter} from '../layouter'; /** * Assumes {@param layout} will only contain 2 views. */ export const withVerticalScrollbarLayout: Layouter = ( layout, containerFrame, ) => { const [contentLayoutInfo, scrollbarLayoutInfo] = layout; const desiredContentSize = contentLayoutInfo.view.desiredSize(); const shouldShowScrollbar = desiredContentSize.height > containerFrame.size.height; const scrollbarWidth = shouldShowScrollbar ? scrollbarLayoutInfo.view.desiredSize().width : 0; const laidOutContentLayoutInfo: LayoutInfo = { ...contentLayoutInfo, frame: { origin: contentLayoutInfo.view.frame.origin, size: { width: containerFrame.size.width - scrollbarWidth, height: containerFrame.size.height, }, }, }; const laidOutScrollbarLayoutInfo: LayoutInfo = { ...scrollbarLayoutInfo, frame: { origin: { x: laidOutContentLayoutInfo.frame.origin.x + laidOutContentLayoutInfo.frame.size.width, y: containerFrame.origin.y, }, size: { width: scrollbarWidth, height: containerFrame.size.height, }, }, }; return [laidOutContentLayoutInfo, laidOutScrollbarLayoutInfo]; };