25 lines
1.3 KiB
TypeScript
25 lines
1.3 KiB
TypeScript
export const STORYBOARD_ROW_HEIGHT = 48;
|
|
export const STORYBOARD_HEADER_HEIGHT = 124;
|
|
|
|
const STORYBOARD_ADD_ROW_HEIGHT = 36;
|
|
export const STORYBOARD_COMPOSER_MIN_HEIGHT = 104;
|
|
const STORYBOARD_COMPOSER_MAX_HEIGHT = 180;
|
|
|
|
// 布局计算属于画布领域逻辑,独立于 React 节点组件,避免纯函数测试加载完整 UI 依赖。
|
|
function normalizedComposerHeight(composerHeight: number) {
|
|
return Math.min(STORYBOARD_COMPOSER_MAX_HEIGHT, Math.max(STORYBOARD_COMPOSER_MIN_HEIGHT, composerHeight));
|
|
}
|
|
|
|
export function storyboardNodeHeight(rowCount: number, composerHeight = STORYBOARD_COMPOSER_MIN_HEIGHT) {
|
|
const visibleRows = Math.min(Math.max(rowCount, 1), 4);
|
|
return STORYBOARD_HEADER_HEIGHT + visibleRows * STORYBOARD_ROW_HEIGHT + STORYBOARD_ADD_ROW_HEIGHT + normalizedComposerHeight(composerHeight);
|
|
}
|
|
|
|
export function storyboardMinNodeHeight(composerHeight = STORYBOARD_COMPOSER_MIN_HEIGHT) {
|
|
return STORYBOARD_HEADER_HEIGHT + STORYBOARD_ROW_HEIGHT + STORYBOARD_ADD_ROW_HEIGHT + normalizedComposerHeight(composerHeight);
|
|
}
|
|
|
|
export function storyboardTableHeight(nodeHeight: number, composerHeight = STORYBOARD_COMPOSER_MIN_HEIGHT) {
|
|
return Math.max(STORYBOARD_ROW_HEIGHT, nodeHeight - STORYBOARD_HEADER_HEIGHT - STORYBOARD_ADD_ROW_HEIGHT - normalizedComposerHeight(composerHeight));
|
|
}
|