Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

570 B
Raw Blame
export const getAnchoredMenuPosition = (bottom: number, targetHeight: number, menuHeight: number,
                                       viewportHeight: number, topBarHeight: number) => {
    const below = Math.max(0, viewportHeight - bottom);
    const above = Math.max(0, bottom - targetHeight - topBarHeight);
    const openAbove = menuHeight > below && (menuHeight <= above || above > below);
    const height = Math.min(menuHeight, openAbove ? above : below);
    return {
        top: openAbove ? bottom - targetHeight - height : bottom,
        height,
    };
};